以太坊java 源码

1 以太坊架构图

https://ethfans.org/topics/840

For reference on all existing options, their description and defaults you may refer to the default config ethereumj.conf (you may find it in either the library jar or in the source tree ethereum-core/src/main/resources) To override needed options you may use one of the following ways:put your options to the <working dir>/config/ethereumj.conf file put user.conf to the root of your classpath (as a resource) put your options to any file and supply it via -Dethereumj.conf.file=<your config> programmatically by using SystemProperties.CONFIG.override*() * programmatically using by overriding Spring SystemProperties bean

EthereumJ.conf

EthereumJ提供了很多的配置选项来差异化的定制系统, 配置文件采用Json的格式。缺省的Ethereumj.conf文件配置了系统的绝大部分参数,一般用户只需要在自己的配置文件,定义很少的参数,如database的文件存储位置,genesis配置文件的位置,系统的privateKey,listening
port等系统外部参数。

l JVM的system property定义的某个参数

l JVM命令行定义的ethereumj.conf.file(-Dethereumj.conf.file)文件位置

l JVM的resource path下的test-user.conf

l JVM的resource path下的test-ethereumj.conf

l OS的user.dir目录下的/config/ehtereumj.conf

l JVM的resource path下的user.conf

l JVM命令行定义的ethereumj.conf.res(-Dethereumj.conf.res)在JVM的resource path下的文件

l 系统缺省的ethereumj.conf

上面列出了配置生效的顺序(优先级从上到下)。


EthereumJ使用Spring Framework来加载各个模块。

以太坊区块链采用Trie结构保存三种数据:

l Account state。

l 每一个block里的Transaction list。

l 每一个block里的TransactionReceipt list。

Block里的Prev Hash与Bitcoin的功能相似,用来建立一个真实完整的区块链。 State Root用来reference到data storage里保存的account states。Transaction Root和Receipt Root分别是本block里的Transaction list和TransactionReceipt list的hash root。

l WorldManager,EthereumJ的主要管理模块,它负责启动EthereumJ一些主要的模块。

n init(),负责启动SyncManager。

n loadBlockchain(),负责加载repository,blockStore和blockChain的数据。


l BlockChain/BlockChainImpl,BlockChain定义了访问以太坊区块链block的接口,BlockChainImpl实现了该接口。

n getXXX()用于得到各种block的信息。

n tryToConnect(Block),用于将新的block加到区块链上。


l Repository/RepositoryRoot(RepositoryImpl),Repostiry定义了访问以太坊区块链的AccoutState的接口,RepositoryRoot(RepositoryImpl)实现了该接口。

n getXXX()用于得到各种account state的信息。

n getRoot()得到block里需要的state
root信息。

n syncToRoot(byte[]),用于跟新repository到新的state root。

n getSnapshotTo(byte[]),用于得到基于新的state root的respository。


l PendingState/PendingSateImpl,由于以太坊区块链采用的是分布式的共识机制确认新的blocks,因此新的blocks的确认需要一个等待窗口,在窗口时间内,可能会有多个blocks分支。PendingState定义了接口来处理这种场景,PendingSateImpl实现了该接口。

n addPendingTransaction(Transaction),加入新的Transaction。

n processBest(Block, List<TransactionReceipt>),处理新的block。


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值