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
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
File details
Details for the file merkle_patricia_trie-0.4.0.tar.gz.
File metadata
- Download URL: merkle_patricia_trie-0.4.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ed7f430587b1e47679c25c5baee51a3a57fcc5423aaf9f05caf1b7176a6e7cd
|
|
| MD5 |
8d2b7edfe65f400592e19a2f1f2fc80d
|
|
| BLAKE2b-256 |
40720f95928c9f9d21259c7900974dfd777688acd5df828ff719f673ac51cb4e
|
File details
Details for the file merkle_patricia_trie-0.4.0-py3-none-any.whl.
File metadata
- Download URL: merkle_patricia_trie-0.4.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1299e0b59dfcf7876582bf631f33d997640051852daaff94625de9f1fe835b3
|
|
| MD5 |
46cb5f5c3392247ef2fcac2eead6c5f3
|
|
| BLAKE2b-256 |
a4bb984d01835a07264525d37bb300b6728a4149772dbef1d3bd6696185ba5dd
|