Python implementation of the Ethereum Trie structure
Project description
# Python Implementation of the Ethereum Trie structure
`shell $ pip install 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 `
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file trie-0.2.4.tar.gz
.
File metadata
- Download URL: trie-0.2.4.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd6fb2dcc9fc583945b262d2a0e0e5dd111a619a787012867e1b0dd0d34fd8a0 |
|
MD5 | d024e98e7a067175f165278a349e47cd |
|
BLAKE2b-256 | 2338d125b675f77b7f8b106d28e96d33bc8fb36ba56806996d473431effc826f |
File details
Details for the file trie-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: trie-0.2.4-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d2c317d1b0937ed127ecac1a4662efa565f435f33f0c5a0f63b8dcaaf36b7ee |
|
MD5 | 504406cac5d94abe73c37ffc6a9b672d |
|
BLAKE2b-256 | 5e42a27df85a7c3214565d7d14268fc1f510e742f1f8acee695d454e283e36ae |