From 3a139d6c7875112ccd325936bb2753e4acd3d640 Mon Sep 17 00:00:00 2001 From: Tuna Date: Thu, 5 Jul 2018 16:46:56 +0700 Subject: [PATCH] masternode[0] will create block 1 --- consensus/clique/clique.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 558ffe7caabe..093ee7dee205 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -406,16 +406,16 @@ func (c *Clique) GetMasternodes(chain consensus.ChainReader, header *types.Heade } func YourTurn(masternodes []common.Address, snap *Snapshot, header *types.Header, cur common.Address) (bool, error) { - if header.Number.Uint64() == 0 { - // Not check signer for genesis block. - return true, nil - } - - pre, err := ecrecover(header, snap.sigcache) - if err != nil { - return false, err + pre := common.Address{} + // masternode[0] has chance to create block 1 + preIndex := -1 + if header.Number.Uint64() != 0 { + pre, err := ecrecover(header, snap.sigcache) + if err != nil { + return false, err + } + preIndex = position(masternodes, pre) } - preIndex := position(masternodes, pre) curIndex := position(masternodes, cur) log.Info("Debugging info", "number of masternodes", len(masternodes), "previous", pre, "position", preIndex, "current", cur, "position", curIndex) for i, s := range masternodes {