diff --git "a/pow\344\270\200\350\207\264\346\200\247\347\256\227\346\263\225.md" "b/pow\344\270\200\350\207\264\346\200\247\347\256\227\346\263\225.md" index c0ea7ab..40fd8ef 100644 --- "a/pow\344\270\200\350\207\264\346\200\247\347\256\227\346\263\225.md" +++ "b/pow\344\270\200\350\207\264\346\200\247\347\256\227\346\263\225.md" @@ -3,6 +3,7 @@ 在CPU挖矿部分,CpuAgent的mine函数,执行挖矿操作的时候调用了self.engine.Seal函数。这里的engine是就是共识引擎。Seal为其中很重要的一个接口。它实现了nonce值的寻找和hash的计算。并且该函数是保证共识并且不能伪造的一个重要的函数。 再PoW共识算法中,Seal函数实现了工作证明。该部分源码在consensus/ethhash下。 ### 共识引擎接口 +``` type Engine interface { // 获取区块挖掘者, 即coinbase Author(header *types.Header) (common.Address, error) @@ -39,6 +40,7 @@ type Engine interface { // APIs 返回由共识引擎提供的RPC APIs APIs(chain ChainReader) []rpc.API } +``` ### ethhash 实现分析 #### ethhash 结构体 ``` @@ -621,4 +623,4 @@ func hashimotoLight(size uint64, cache []uint32, hash []byte, nonce uint64) ([]b } return hashimoto(hash, nonce, size, lookup) } -``` \ No newline at end of file +```