ethereumjs/merkle-patricia-tree-2-API
SecureTrie
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相同的方法和构造函数
Trie
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是相同的。
Parameters参数
dbObject? An instance of levelup or a compatible API. If the db isnullor left undefined, then the trie will be stored in memory via memdown levelup实例或一个兼容API。如果db为null或undefined,那么trie将通过memdown存储到内存中root(Buffer | String)? A hexStringorBufferfor the root of a previously stored trie 以前存储的trie的根,为一个十六进制字符串或buffer
Properties属性
rootBuffer The current root of thetrie 当前trie的根isCheckpointBoolean determines if you are saving to a checkpoint or directly to the db 决定是保存到检查点还是直接保存到数据库EMPTY_TRIE_ROOTBuffer the Root for an empty trie 空trie的根
get
Gets a value given a key
得到给定key的value
Parameters参数
key(Buffer | String) the key to search for 搜索的keycbFunction A callbackFunctionwhich is given the argumentserr- for errors that may have occured andvalue- the found value in aBufferor if no value was foundnull 有给定参数err-可能发生的错误和value-在Buffer中发现的value,如果没有则为null的回调函数
put
Stores a given value at the given key
在给定的key上存储给定的value
Parameters参数
key(Buffer | String)Value(Buffer | String)cbFunction A callbackFunctionwhich is given the argumenterr- for errors that may have occured 有给定参数err-可能发生的错误的回调函数
del
deletes a value given a key
删除给定key的value
Parameters
getRaw
Retrieves a raw value in the underlying db
检索底层数据库中的原始value
Parameters
keyBuffercallbackFunction A callbackFunction, which is given the argumentserr- for errors that may have occured andvalue- the found value in aBufferor if no value was foundnull.有给定参数err-可能发生的错误和value-在Buffer中发现的value,如果没有则为null的回调函数
putRaw
Writes a value directly to the underlining db
直接将value写入底层数据库
Parameters
key(Buffer | String) The key as aBufferorString Buffer或String类型的keyvalueBuffer The value to be stored 存储的valuecallbackFunction A callbackFunction, which is given the argumenterr- for errors that may have occured 有给定参数err-可能发生的错误的回调函数
delRaw
Removes a raw value in the underlying db
移除在底层数据库中的原始数据
Parameters
key(Buffer | String)callbackFunction A callbackFunction, which is given the argumenterr- for errors that may have occured有给定参数err-可能发生的错误的回调函数
findPath
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的堆栈
Parameters参数
null-null(String | Buffer) key - the search key 搜索keynull-nullFunction 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
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
The given hash of operations (key additions or deletions) are executed on the DB
给定的要执行在数据库上的操作(key添加或删除)的hash
Parameters
Examples
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
Checks if a given root exists
检查给定的root是否存在
Parameters
Merkle Proof Merkle证明
Static functions for creating/verifying a merkle proof.
创建/验证Merkle证明的静态函数
prove
Returns a merkle proof for a given key
根据给定key返回merkle证明
Parameters
trieTriekeyStringcbFunction A callbackFunction(arguments {Error}err, {Array.}proof) 回调函数fun(err,proof)
verifyProof
Verifies a merkle proof for a given key
根据给定key验证merkle证明
Parameters
rootHashBufferkeyStringproofArray<TrieNode>cbFunction A callbackFunction(arguments {Error}err, {String}val) 回调函数fun(err,val)
Internal Util Functions 内部Util函数
These are not exposed.这些函数是不暴露给外部用户的
addHexPrefix
Parameters
keyterminatordataArrArray
Returns Buffer returns buffer of encoded data hexPrefix *
返回类型为Buffer,返回添加了十六进制前缀的编码数据的buffer
asyncFirstSeries
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
Parameters
arrayiteratorcb
callTogether
Take two or more functions and returns a function that will execute all of the given functions
调用两个或更多函数,然后返回一个执行所有给定函数的函数
doKeysMatch
Compare two 'nibble array' keys
比较两个半字节数组keys
Parameters
keyAkeyB
ethereumjs/merkle-patricia-tree-2-API的更多相关文章
- 014-数据结构-树形结构-基数树、Patricia树、默克尔树、梅克尔帕特里夏树( Merkle Patricia Tree, MPT)
一.基数树 Radix树,即基数树,也称压缩前缀树,是一种提供key-value存储查找的数据结构.与Trie不同的是,它对Trie树进行了空间优化,只有一个子节点的中间节点将被压缩.同样的,Radi ...
- Merkle Patricia Tree (MPT) 树详解
1. 介绍 Merkle Patricia Tree(简称MPT树,实际上是一种trie前缀树)是以太坊中的一种加密认证的数据结构,可以用来存储所有的(key,value)对.以太坊区块的头部包 ...
- Merkle Patricia Tree (MPT) 以太坊中的默克尔树
本篇博文是自己学习mpt的过程,边学边记录,很多原理性内容非自己原创,好的博文将会以链接形式进行共享. 一.什么是mpt MPT是以太坊中的merkle改进树,基于基数树,即前缀树改进而来,大大提高了 ...
- 使用 Jackson 树模型(tree model) API 处理 JSON
http://blog.csdn.net/gao1440156051/article/details/54091702 http://blog.csdn.net/u010003835/article/ ...
- Merkle Tree学习
/*最近在看Ethereum,其中一个重要的概念是Merkle Tree,以前从来没有听说过,所以查了些资料,学习了Merkle Tree的知识,因为接触时间不长,对Merkle Tree的理解也不是 ...
- Merkle Tree 概念
Merkle Tree 概念 来源 https://www.cnblogs.com/fengzhiwu/p/5524324.html /*最近在看Ethereum,其中一个重要的概念是Merkle T ...
- Merkle Tree(默克尔树)算法解析
Merkle Tree概念 Merkle Tree,通常也被称作Hash Tree,顾名思义,就是存储hash值的一棵树.Merkle树的叶子是数据块(例如,文件或者文件的集合)的hash值.非叶节点 ...
- 转 Merkle Tree(默克尔树)算法解析
Merkle Tree概念 Merkle Tree,通常也被称作Hash Tree,顾名思义,就是存储hash值的一棵树.Merkle树的叶子是数据块(例如,文件或者文件的集合)的hash值.非叶节 ...
- 区块链~Merkle Tree(默克尔树)算法解析~转载
转载~Merkle Tree(默克尔树)算法解析 /*最近在看Ethereum,其中一个重要的概念是Merkle Tree,以前从来没有听说过,所以查了些资料,学习了Merkle Tree的知识,因为 ...
- ethereumjs/merkle-patricia-tree-1-简介
https://github.com/ethereumjs/merkle-patricia-tree SYNOPSIS概要 This is an implementation of the modif ...
随机推荐
- Java基础教程(5)--变量
一.变量 1.变量的定义 正如上一篇教程<Java基础教程(4)--面向对象概念>中介绍的那样,对象将它的状态存在域中.但是你可能仍然有一些疑问,例如:命名一个域的规则和惯例是什么?除 ...
- HDOJ2037 今年暑假不AC (经典的贪心问题)
Description “今年暑假不AC?” “是的.” “那你干什么呢?” “看世界杯呀,笨蛋!” “@#$%^&*%...” 确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会 ...
- Java与C++区别:重载(Overloading)
Java中一个类的函数重载可以在本类中的函数和来自父类中的函数之间进行,而C++类中的函数重载只能是本类中的(即不包括来自父类的函数),这是他们一个非常重要的区别.在其他方面的要求都是一致的,即要求函 ...
- BZOJ5372: PKUSC2018神仙的游戏
传送门 Sol 自己还是太 \(naive\) 了,上来就构造多项式和通配符直接匹配,然后遇到 \(border\) 相交的时候就 \(gg\) 了 神仙的游戏蒟蒻还是玩不来 一个小小的性质: 存在长 ...
- 1739 GPA排序 个人博客:doubleq.win
个人博客:doubleq.win 1739 GPA排序 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 青铜 Bronze 题解 题目描述 Description ...
- less教程
平时在工作中,偶尔会遇到老大让你修改原来写好的样式,如果修改的多的话,修改起来是非常麻烦的.他不像js一样,定义变量.函数,需要修改某些值,直接修改方法就行了.less的出现,恰恰帮我们解决了这个问题 ...
- IhyerDB modBus采集器配置.
近期查了一下ihyerDB-modbus采集器的相关配置,由于没有相关的modbus设备,于是今天上午根据网上的线索下载了Modbus Slave(modbus从站仿真器).笔记本也没有串口,于是下载 ...
- 配置文件出错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): <!-- mybatis 配置- ...
- Windows下本机简易监控系统搭建(Telegraf+Influxdb+Grafana)
一.文件准备 1.1 文件名称 telegraf-1.2.1_windows_amd64.zip influxdb-1.2.2_windows_amd64.zip grafana-4.2.0.wind ...
- Android ListView实现新闻客户端的新闻内容图文混排
布局文件: <LinearLayout xmlns:android="<a href="http://schemas.android.com/apk/res/andro ...