# Python Implementation of the Ethereum Trie structure
`shell $ pip install ethereum-trie `
> Warning: This is an early release and is likely to contain bugs as well as > breaking API changes.
# Usage
`python >>> from trie import Trie >>> from trie.db.memory import MemoryDB >>> t = Trie(MemoryDB()) >>> t.root_hash b'V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!' >>> t.set(b'my-key', b'some-value') >>> t.get(b'my-key') b'some-value' >>> t.exists(b'another-key') False >>> t.set(b'another-key', b'another-value') >>> t.exists(b'another-key') True >>> t.delete(b'another-key') >>> t.exists(b'another-key') False `
You can also use it like a dictionary.
`python >>> from trie import Trie >>> from trie.db.memory import MemoryDB >>> t = Trie(MemoryDB()) >>> t.root_hash b'V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!' >>> t[b'my-key'] = b'some-value' >>> t[b'my-key'] b'some-value' >>> b'another-key' in t False >>> t[b'another-key'] = b'another-value' >>> b'another-key' in t True >>> del t[b'another-key'] >>> b'another-key' in t False `
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ethereum-trie-0.1.0.tar.gz.
File metadata
- Download URL: ethereum-trie-0.1.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea40c97b92c5e681ef9daf305f0f28f16b553f134580d0b65de359b73b0a12ba
|
|
| MD5 |
ffe23b578073a31f86efd5c4c3cb089e
|
|
| BLAKE2b-256 |
061b9cd49f5f053eb2d8ae44d767a1c8aad0aab1a050fe36f92de49628b028e1
|