Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trie-0.2.3.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

trie-0.2.3-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file trie-0.2.3.tar.gz.

File metadata

  • Download URL: trie-0.2.3.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for trie-0.2.3.tar.gz
Algorithm Hash digest
SHA256 dc1e23924c54920a668b3cf5a5e8461b7921af8cd454a6c4fa951bda7966968c
MD5 dba4f1a0b94128eb7c8d9eb039400b91
BLAKE2b-256 39237541f8d5de45dac06243122dc022ebbc795986a052ae7c032ea0bc6b3616

See more details on using hashes here.

File details

Details for the file trie-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for trie-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f3a121bd64b9f026239827a0d538a6f3524abff17fc1b52640aa9de0aae4519f
MD5 a5ebc78be8f853285111e03a79a03aa5
BLAKE2b-256 fa71035eb3044ba66f3f9f7dc04d5160d1014a227d97aa6c87c90f128c5837ac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page