From adc187d31aeac0c3c969e28395a8b2ea5970cf20 Mon Sep 17 00:00:00 2001 From: firesh Date: Tue, 7 Jan 2020 11:02:41 +0800 Subject: [PATCH] =?UTF-8?q?Update=20pow=E4=B8=80=E8=87=B4=E6=80=A7?= =?UTF-8?q?=E7=AE=97=E6=B3=95.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改代码的格式 --- ...70\200\350\207\264\346\200\247\347\256\227\346\263\225.md" | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 +```