跳转到主要内容

Ethereum Trie结构的Python实现

项目描述

# Python Implementation of the Ethereum Trie structure

`shell $ pip install ethereum-trie `

> 警告:这是一个早期版本,可能包含错误以及 > 破坏API的更改。

# 使用方法

`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 `

您也可以像使用字典一样使用它。

`python >>> 从 trie 导入 Trie >>> 从 trie.db.memory 导入 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 `

项目详情


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源代码分发

ethereum-trie-0.1.0.tar.gz (6.1 kB 查看哈希)

上传时间 源代码

由以下支持