src/secure.js:10-15
Extends Trie 扩展前缀树
You can create a secure Trie where the keys are automatically hashed using
SHA3
by using
require('merkle-patricia-tree/secure')
. It has the same methods and constructor as
Trie
.
你可以
通过使用
require('merkle-patricia-tree/secure')
创建一个keys会自动使用
SHA3
进行hash的安全前缀树。它有着与
Trie
相同的方法和构造函数
src/baseTrie.js:27-55
Use
require('merkel-patricia-tree')
for the base interface. In Ethereum applications stick with the Secure Trie Overlay
require('merkel-patricia-tree/secure')
. The API for the raw and the secure interface are about the same
使用
require('merkel-patricia-tree')
获取基本接口。在Ethereum应用程序坚持使用安全的Trie,即
require('merkel-patricia-tree/secure')。对于原始的和安全的
Trie
的接口的API是相同的。
db
Object
?
An instance of
levelup
or a compatible API. If the db is
null
or left undefined, then the trie will be stored in memory via
memdown
levelup实例或一个兼容API。如果db为null或undefined,那么
trie
将通过
memdown存储到内存中
root
(
Buffer
|
String
)?
A hex
String
or
Buffer
for the root of a previously stored trie 以前存储的
trie
的根,为一个十六进制字符串或buffer
root
Buffer
The current root of the
trie 当前
trie
的根
isCheckpoint
Boolean
determines if you are saving to a checkpoint or directly to the db 决定是保存到检查点还是直接保存到数据库
EMPTY_TRIE_ROOT
Buffer
the Root for an empty trie 空
trie
的根
key
(
Buffer
|
String
)
The key as a
Buffer
or
String Buffer或String类型的key
value
Buffer
The value to be stored 存储的value
callback
Function
A callback
Function
, which is given the argument
err
- for errors that may have occured
有
给
定参数err-可能发生的错误
的回调函数
delRaw
src/baseTrie.js:214-221
Removes a raw value in the underlying db
移除在底层数据库中的原始数据
key
(
Buffer
|
String
)
callback
Function
A callback
Function
, which is given the argument
err
- for errors that may have occured
有
给
定参数err-可能发生的错误
的回调函数
findPath
src/baseTrie.js:256-304
Trys to find a path to the node for the given key It returns a
stack
of nodes to the closet node
根据给定key尝试找到node的path。其返回到最近节点node的nodes的堆栈
null-null
(
String
|
Buffer
)
key - the search key 搜索key
null-null
Function
cb - the callback function. Its is given the following arguments
回调函数,给定以下参数
err - any errors encontered 遇见的错误
node - the last node found 最后找到的节点node
keyRemainder - the remaining key nibbles not accounted for 剩余的没有找到半个字节的key
stack - an array of nodes that forms the path to node we are searching for 一个节点数组,它构成我们正在搜索的节点的路径
createReadStream
src/baseTrie.js:723-725
The
data
event is given an
Object
hat has two properties; the
key
and the
value
. Both should be Buffers.
data
事件给了带有两个属性的对象:
key
和
value
,都为Buffer类型
Returns
stream.Readable
Returns a
stream
of the contents of the
trie
返回类型是
stream.Readable
,返回
trie
内容的流
batch
src/baseTrie.js:749-761
The given hash of operations (key additions or deletions) are executed on the DB
给定的要执行在数据库上的操作(key添加或删除)的hash
ops
Array
操作的数组
cb
Function
var ops = [
{ type: 'del', key: 'father' }
, { type: 'put', key: 'name', value: 'Yuri Irsenovich Kim' }
, { type: 'put', key: 'dob', value: '16 February 1941' }
, { type: 'put', key: 'spouse', value: 'Kim Young-sook' }
, { type: 'put', key: 'occupation', value: 'Clown' }
trie.batch(ops)
checkRoot
src/baseTrie.js:770-775
Checks if a given root exists
检查给定的root是否存在
root
Buffer
cb
Function
Merkle Proof Merkle证明
Static functions for creating/verifying a merkle proof.
创建/验证Merkle证明的静态函数
src/proof.js:12-29
Returns a merkle proof for a given key
根据给定key返回merkle证明
trie
Trie
key
String
cb
Function
A callback
Function
(arguments {Error}
err
, {Array.}
proof
) 回调函数fun(err,proof)
verifyProof
src/proof.js:39-100
Verifies a merkle proof for a given key
根据给定key验证merkle证明
rootHash
Buffer
key
String
proof
Array
<TrieNode>
cb
Function
A callback
Function
(arguments {Error}
err
, {String}
val
)
回调函数fun(err,val)
Internal Util Functions 内部Util函数
These are not exposed.这些函数是不暴露给外部用户的
src/trieNode.js:164-179
terminator
dataArr
Array
Returns
Buffer
returns buffer of encoded data hexPrefix *
返回类型为Buffer,返回添加了十六进制前缀的编码数据的buffer
asyncFirstSeries
src/util.js:63-79
Take a collection of async fns, call the cb on the first to return a truthy value. If all run without a truthy result, return undefined
异步函数的收集,调用第一个参数上的回调返回可信value。如果所有运行没有可信结果,返回undefined
array
iterator
callTogether
src/util.js:37-57
Take two or more functions and returns a function that will execute all of the given functions
调用两个或更多函数,然后返回一个执行所有给定函数的函数
src/util.js:28-31
Compare two 'nibble array' keys
比较两个半字节数组keys