ethereumjs/ethereumjs-vm-3-StateManager
https://github.com/ethereumjs/ethereumjs-vm/blob/master/docs/stateManager.md
StateManager
要与本博客的ethereumjs/ethereumjs-account-1-简介和API结合学习,然后你就能够发现StateManager其实就是得到账户中的值。账户 = 账户地址address + 账户状态(有nonce,balance,stateRoot,codeHash)。下面的方法得到或处理的就是账户中对应的这些数据信息
Interface for getting and setting data from an underlying state trie
从下面的状态前缀树得到和设置数据的接口
getAccount
Gets the ethereumjs-account associated with address. Returns an empty account if the account does not exist.
得到ethereumjs-account关联的地址。如果账户不存在则返回空账户
Parameters参数
addressBuffer Address of theaccountto get 要得到的账户的地址cbgetAccount~callback 回调函数
getAccount~callback
Callback for getAccount method
Type: Function
Parameters
errorError an error that may have happened ornull 出现的错误或者nullaccountAccount Anethereumjs-accountinstance corresponding to the providedaddress 与提供的地址关联的ethereumjs-account实例
putAccount
Saves an ethereumjs-account into state under the provided address
将 ethereumjs-account保存在提供的地址下的状态中
Parameters
addressBuffer Address under which to storeaccount 在该地址下存储账户accountAccount Theethereumjs-accountto store 存储的ethereumjs-account账户cbFunction Callback function 回调函数
putContractCode
Adds value to the state trie as code, and sets codeHash on the account corresponding to address to reference this.
把值作为代码存储到状态前缀树中,并设置关联地址的账户的codeHash来引用它
Parameters
addressBuffer Address of theaccountto add thecodefor 为了该账户地址添加代码valueBuffer The value of thecode 代码的值cbFunction Callback function 回调函数
getContractCode
Gets the code corresponding to the provided address
得到与提供的地址相关联的代码
Parameters参数
addressBuffer Address to get thecodefor 为了该地址取得代码cbgetContractCode~callback回调函数
getContractCode~callback
Callback for getContractCode method
getContractCode方法的回调函数
Type: Function
Parameters
errorError an error that may have happened ornull出现的错误或者nullcodeBuffer The code corresponding to the provided address. Returns an emptyBufferif the account has no associated code. 与提供的代码相关联的代码。如果该账户没有相关联的代码就返回空Buffer
getContractStorage
Gets the storage value associated with the provided address and key
得到与提供的地址和key相关联的存储值
Parameters
addressBuffer Address of the account to get the storage for 为了该账户地址取得存储值keyBuffer Key in the account's storage to get the value for 得到值需要的账户存储中的keycbgetContractCode~callback
getContractStorage~callback
Callback for getContractStorage method
getContractStorage方法的回调
Type: Function
Parameters
errorError an error that may have happened ornull出现的错误或者nullstorageValueBuffer The storage value for the account corresponding to the provided address at the provided key. If this does not exists an emptyBufferis returned 与提供的地址相关联的账户在提供的key处得到的存储值。如果不存在则返回空Buffer
putContractStorage
Adds value to the state trie for the account corresponding to address at the provided key
为了与地址相关联的账户在提供的key上给状态树添加值
Parameters
addressBuffer Address to set a storage value for 为了该地址设置值keyBuffer Key to set the value at 将值设置在该key上valueBuffer Value to set atkeyfor account corresponding toaddress 为了与地址相关联的账户在key上设置的值cbFunction Callback function 回调
clearContractStorage
Clears all storage entries for the account corresponding to address
为了与地址相关联的账户清理所有存储条目
Parameters
checkpoint检查点
Checkpoints the current state of the StateManager instance. State changes that follow can then be committed by calling commit or reverted by calling rollback.
检查点是StateManager实例的当前状态。随后的状态更改可以通过调用commit提交,也可以通过调用rollback返回
Parameters
cbFunction Callback function 回调函数
commit提交
Commits the current change-set to the instance since the last call to checkpoint.
提交目前的状态-设置为从上次调用检查点以来的实例
Parameters
cbFunction Callback function回调
revert
Reverts the current change-set to the instance since the last call to checkpoint.
恢复当前的变化-设置为从上次调用检查点以来的实例
Parameters
cbFunction Callback function
getStateRoot
Gets the state-root of the Merkle-Patricia trie representation of the state of this StateManager. Will error if there are uncommitted checkpoints on the instance.
得到StateManager状态的Merkle-Patricia前缀树表示的状态根。如果在实例中有未提交的检查点将出错
Parameters
getStateRoot~callback
Callback for getStateRoot method
getStateRoot方法的回调
Type: Function
Parameters
errorError an error that may have happened ornull. Will be an error if the un-committed checkpoints on the instance. 出现的错误或null。如果在示例中有没提交的检查点将会变成一个错误stateRootBuffer The state-root of theStateManagerStateManager的状态根
setStateRoot
Sets the state of the instance to that represented by the provided stateRoot. Will error if there are uncommitted checkpoints on the instance or if the state root does not exist in the state trie.
设置通过提供的stateRoot表示的实例的状态。如果在实例中有未提交的检查点或在状态前缀树中状态根不存在将出错
Parameters
stateRootBuffer The state-root to reset the instance to 重置的实例的状态根cbFunction Callback function 回调函数
generateCanonicalGenesis
Generates a canonical genesis state on the instance based on the configured chain parameters. Will error if there are uncommitted checkpoints on the instance.
基于在配置链参数在实例上生成规范生成状态。如果在实例上有未提交的检查点则出错
Parameters
cbFunction Callback function 回调函数
accountIsEmpty
Checks if the account corresponding to address is empty as defined in EIP-161 (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-161.md)
查看与地址相关联的账户是否为空,就像 EIP-161中定义的一样。可看本博客(ethereum/EIPs-161 State trie clearing)
Parameters
addressBuffer Address to check 查看的地址cbaccountIsEmpty~callback
accountIsEmpty~callback
Callback for accountIsEmpty method
accountIsEmpty方法的回调
Type: Function
Parameters
errorError an error that may have happened ornull出现的错误或者nullemptyBoolean True if the account is empty false otherwise 如果账户为空则返回true,否则为false
cleanupTouchedAccounts
Removes accounts form the state trie that have been touched, as defined in EIP-161 (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-161.md).
从状态前缀树中删除已修改的帐户,就像 EIP-161中定义的一样。可看本博客(ethereum/EIPs-161 State trie clearing)
Parameters
cbFunction Callback function
DefaultStateManager默认的StateManager
Default implementation of the StateManager interface
StateManager接口的默认实现
Parameters
optsObject (optional, default{})opts.commonCommon?Commonparameters of the chain 链的Common参数opts.trieTrie? amerkle-patricia-treeinstancemerkle-patricia-tree实例
copy
Copies the current instance of the DefaultStateManager at the last fully committed point, i.e. as if all current checkpoints were reverted
在最后的完全提交点复制当前的DefaultStateManager实例,比如好像所有当前检查点都恢复了
dumpStorage
Dumps the the storage values for an account specified by address
为了被地址指定的账户倾倒存储值
Parameters
addressBuffer The address of theaccountto return storage for 为了改账户地址返回存储值cbdumpStorage~callback
dumpStorage~callback
Callback for dumpStorage method
dumpStorage方法的回调
Type: Function
Parameters
errorError an error that may have happened ornull 出现的错误或nullaccountStateObject The state of the account as anObjectmap. Keys are are the storage keys, values are the storage values as strings. Both are represented as hex strings without the0xprefix.作为对象映射的账户状态。Keys是存储键,values是字符串的存储值。都是没有0x前缀的十六进制表示的
hasGenesisState
Checks whether the current instance has the canonical genesis state for the configured chain parameters.
为了配置链参数查看是否当前的实例有规范生成状态
Parameters
hasGenesisState~callback
Callback for hasGenesisState method
hasGenesisState方法的回调
Type: Function
Parameters
errorError an error that may have happened ornull出现的错误或nullhasGenesisStateBoolean Whether the storage trie contains the canonical genesis state for the configured chain parameters. 存储前缀树是否为了配置链参数包含了规范生成状态
generateGenesis
Initializes the provided genesis state into the state trie
将提供的生成状态初始化到状态前缀树中
Parameters
ethereumjs/ethereumjs-vm-3-StateManager的更多相关文章
- ethereumjs/ethereumjs-vm-1-简介
https://github.com/ethereumjs/ethereumjs-vm 其实这就是怎么自己使用该模块来生成一个类似geth客户端的以太坊虚拟机,然后进行各类区块链操作 SYNOPSIS ...
- ethereumjs/ethereumjs-vm-2-API文档
https://github.com/ethereumjs/ethereumjs-vm/blob/master/docs/index.md vm.runBlockchain Processes blo ...
- ethereumjs/ethereumjs-vm-4-tests
根据代码发现还要了解的模块有: ethereumjs/merkle-patricia-tree -对应数据存储的数据结构 ethereumjs-blockchain —— 区块链 ethereumjs ...
- ethereumjs/ethereumjs-util
ethereumjs/ethereumjs-util Most of the string manipulation methods are provided by ethjs-util 更多的字符串 ...
- ethereumjs/ethereumjs-common-1-简介
为了了解ethereumjs/ethereumjs-block-3-代码的使用需要了解的一个模块 https://github.com/ethereumjs/ethereumjs-common Com ...
- ethereumjs/ethereumjs-common-2-API文档
https://github.com/ethereumjs/ethereumjs-common/blob/master/docs/index.md 该API的调用的详细例子可见ethereumjs/e ...
- ethereumjs/browser-builds
https://github.com/ethereumjs/browser-builds ethereumjs - Browser Builds This repository contains br ...
- ethereumjs/ethereumjs-blockchain-2-test
https://github.com/ethereumjs/ethereumjs-blockchain/tree/master/test 'use strict' const test = requi ...
- ethereumjs/ethereumjs-blockchain-1-简介和API
https://github.com/ethereumjs/ethereumjs-blockchain SYNOPSIS概要 A module to store and interact with b ...
随机推荐
- java 通用对象排序
一个排序类,一个排序util? no.no.no…… 使用反射机制,写了一个通用的对象排序util,欢迎指正. 实体类: package entity; public class BaseTypeEn ...
- Java 的 委托 是什么?
前言:在学习设计模式时,发现书中有多次提到委托二字,所以经过网上搜索得到结果,并自己写了个小小的例子. 什么是委托? 委托模式是软件设计模式中的一项基本技巧.在委托模式中,有两个对象参与处理同一个请求 ...
- K:大数加法
相关介绍: 在java中,整数是有最大上限的.所谓大数是指超过整数最大上限的数,例如18 452 543 389 943 209 789 324 233和8 123 534 323 432 323 ...
- vmware 虚拟机导入OVF出现路径错误
现状: 需要将原有数据中心的VM虚拟机导出本地OVF模板,然后迁移至新的机房虚拟化环境后从新导入. 问题: 导入OVF时候,先出现错误问题1,修复完成后,出现错误问题2 1. OVF迁移至本地以后,导 ...
- 开博缘由 , 可点下看看 http://www.cnblogs.com/jshare
记录日常用中用到.遇到的问题 实现过程,仅供参考 不定时更新 ------------------- 之前看过一个文章,大概说的是开发和用到的过的代码,可以提取出一些代码片段,长时间下来,你会发现部分 ...
- linux_day3
1.grep与find的区别? grep是查找文件内的字符而find则是查找文件 2.显示/etc/passwd中以nologin结尾的行 3. 输入ip addr命令后,过滤出包含ip的行 ip a ...
- win10_64位系统下安装ALM12.01(QC),笔者只在Win10平台上试过,大家也可以在win7的平台上试一下,一个道理!(Alpha)
HP的ALM是一个非常全面的缺陷管理系统,但安装学习的非常的麻烦,以前学的是ALM,好久没用带今天想学习一下发现安装的非常的困难 !发现网上对ALM的系统安装的介绍非常少,也非常琐碎!今天就借着自己学 ...
- JavaScript的本地对象、内置对象、宿主对象
首先解释下宿主环境:一般宿主环境由外壳程序创建与维护,只要能提供js引擎执行的环境都可称之为外壳程序.如:web浏览器,一些桌面应用系统等.即由web浏览器或是这些桌面应用系统早就的环境即宿主环境. ...
- PG数据库空间大小及数据库对象占用空间大小
select pg_size_pretty(pg_database_size('lrisk')); --查询数据库剩余空间 select pg_database.datname,pg_size_pre ...
- python之内置函数,匿名函数
什么是内置函数? 就是Python给你提供的,拿来直接用的函数,比如print,input等等.其实就是我们在创建.py的时候python解释器所自动生成的内置的函数,就好比我们之前所学的作用空间 内 ...