[h1]源码[/h1]GitHub地址 https://github.com/TTCECO/gttc
[h1]目录[/h1]基于以太坊go-ethereum的DPOS实现(一)源码及测试运行
基于以太坊go-ethereum的DPOS实现(二)简要说明
基于以太坊go-ethereum的DPOS实现(三)创世块
基于以太坊go-ethereum的DPOS实现(四)共识接口
基于以太坊go-ethereum的DPOS实现(五)定时出块
[h1]共识接口[/h1]在go-ethereum中添加一种共识机制,最方便的方式是实现consensus.go中Engine接口所定义的方法。
[code]// Engine is an algorithm agnostic consensus engine.type Engine interface { // Author retrieves the Ethereum address of the account that minted the given // block, which may be different from the header's coinbase if a consensus // engine is based on signatures. Author(header *types.Header) (common.Address, error) // VerifyHeader checks whether a header conforms to the consensus rules of a // given engine. Verifying the seal may be done optionally here, or explicitly // via the VerifySeal method. VerifyHeader(chain ChainReader, header *types.Header, seal bool) error // VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers // concurrently. The method returns a quit channel to abort the operations and // a results channel to retrieve the async verifications (the order is that of // the input slice). VerifyHeaders(chain ChainReader, headers []*types.Header, seals []bool) (chan |
|