From 993267d311c8d5f30fc97737a39eb0082615da71 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Fri, 22 Dec 2017 18:31:25 +0800 Subject: [PATCH] consensus: add docs for calcDifficulty function --- consensus/clique/clique.go | 1 + consensus/ethash/consensus.go | 1 + 2 files changed, 2 insertions(+) diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 4db2a27bcb..1b693f75b3 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -661,6 +661,7 @@ func (c *Clique) CalcDifficulty(chain consensus.ChainReader, time uint64, parent return CalcDifficulty(snap, c.signer) } +// CalcDifficulty returns block difficulty according to local signer is the inturn signer or not. func CalcDifficulty(snap *Snapshot, signer common.Address) *big.Int { if snap.inturn(snap.Number+1, signer) { return new(big.Int).Set(diffInTurn) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index eef6fb0df2..34f73d1f42 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -291,6 +291,7 @@ func (ethash *Ethash) CalcDifficulty(chain consensus.ChainReader, time uint64, p return CalcDifficulty(chain.Config(), time, parent) } +// CalcDifficulty returns block difficulty according to the parent block's time and difficulty. func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int { next := new(big.Int).Add(parent.Number, big1) switch {