Modified Merkle Paticia Trie
MPT is the data structure used in Ethereum as a cryptographically authenticated key-value data storage.
This library is a Python implementation of Modified Merkle Patrica Trie with a very simple interface.
Example
storage = {}
trie = MerklePatriciaTrie(storage)
trie.update(b'do', b'verb')
trie.update(b'dog', b'puppy')
trie.update(b'doge', b'coin')
trie.update(b'horse', b'stallion')
old_root = trie.root()
old_root_hash = trie.root_hash()
print("Root hash is {}".format(old_root_hash.hex()))
trie.delete(b'doge')
print("New root hash is {}".format(trie.root_hash().hex()))
trie_from_old_hash = MerklePatriciaTrie(storage, root=old_root)
print(trie_from_old_hash.get(b'doge'))
try:
print(trie.get(b'doge'))
except KeyError:
print('Not accessible in a new trie.')
Testing
python -m unittest
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
eth_mpt-0.1.0.tar.gz
(9.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
eth_mpt-0.1.0-py3-none-any.whl
(12.2 kB
view details)
File details
Details for the file eth_mpt-0.1.0.tar.gz.
File metadata
- Download URL: eth_mpt-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e2e9628c2d3082e06f69f67f1586caf07f6c510fbb480d39d01c7474f92b10f
|
|
| MD5 |
defd4269d2a3f5174cc8d7d199b45556
|
|
| BLAKE2b-256 |
2e9fd54426edff519c323843b1c21cdc2d325be8b54caf52014e435e733a04b5
|
File details
Details for the file eth_mpt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: eth_mpt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45572af993b73da5c54e7cfd0423bf7d5f47dc63ff6060ec18ea06009e1801c8
|
|
| MD5 |
414d06669449d24f522ce6aedd392d8c
|
|
| BLAKE2b-256 |
aa158d0a02777d85622e3ed25e2d2a44ef5f99d137f4ee6c9e83455a603187d8
|