A simlpe Merkle Patricia Trie implementation
Project description
Credits
This is a fork of eth_mpt package with minor improvements.
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.')
Installing
Install and update using pip:
pip install -U mercle_patricia_trie
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
merkle-patricia-trie-0.3.0.tar.gz
(10.5 kB
view hashes)
Built Distribution
Close
Hashes for merkle-patricia-trie-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 547094792326d92548150227cc092c178b9acfd82bde850c5bbcc00b4b43a591 |
|
MD5 | d29194160cf7a03bbe6d8f04ef39e8fe |
|
BLAKE2b-256 | e8c4f9ef41d2e6aa6b87ab309d01450abd144389cc62c2d99d6752ab93827e73 |
Close
Hashes for merkle_patricia_trie-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 525dc2becfc3d1c2f14b11b3627e3df858d42849f18046817bb1df8c4dc105b3 |
|
MD5 | 813dfc712f2494a584813074011e8c9b |
|
BLAKE2b-256 | dc19b7d4d705df6a92bbed76b353c542b7381c03e9ec808e8ffebed623f4aafa |