From aee70ae30bb4e0cd1532308ae07588bf31123150 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Sat, 5 Aug 2017 13:44:45 +0300 Subject: [PATCH 1/2] consensus: fix megacheck warnings --- consensus/clique/clique.go | 2 +- consensus/clique/snapshot.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index d2fb6934b9..21f048ce38 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -619,7 +619,7 @@ func (c *Clique) Seal(chain consensus.ChainReader, block *types.Block, stop <-ch } } // Sweet, the protocol permits us to sign the block, wait for our time - delay := time.Unix(header.Time.Int64(), 0).Sub(time.Now()) + delay := time.Until(time.Unix(header.Time.Int64(), 0)) if header.Difficulty.Cmp(diffNoTurn) == 0 { // It's not our turn explicitly to sign, delay it a bit wiggle := time.Duration(len(snap.Signers)/2+1) * wiggleTime diff --git a/consensus/clique/snapshot.go b/consensus/clique/snapshot.go index 32a1191dbe..9ebdb8df15 100644 --- a/consensus/clique/snapshot.go +++ b/consensus/clique/snapshot.go @@ -229,9 +229,9 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) { // Tally up the new vote from the signer var authorize bool switch { - case bytes.Compare(header.Nonce[:], nonceAuthVote) == 0: + case bytes.Equal(header.Nonce[:], nonceAuthVote): authorize = true - case bytes.Compare(header.Nonce[:], nonceDropVote) == 0: + case bytes.Equal(header.Nonce[:], nonceDropVote): authorize = false default: return nil, errInvalidVote From 80de4dc72c8d9967fdb3b40e9a8790c87e1400b5 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Mon, 7 Aug 2017 14:32:03 +0300 Subject: [PATCH 2/2] consensus: revert time.Until change --- consensus/clique/clique.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 21f048ce38..d2fb6934b9 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -619,7 +619,7 @@ func (c *Clique) Seal(chain consensus.ChainReader, block *types.Block, stop <-ch } } // Sweet, the protocol permits us to sign the block, wait for our time - delay := time.Until(time.Unix(header.Time.Int64(), 0)) + delay := time.Unix(header.Time.Int64(), 0).Sub(time.Now()) if header.Difficulty.Cmp(diffNoTurn) == 0 { // It's not our turn explicitly to sign, delay it a bit wiggle := time.Duration(len(snap.Signers)/2+1) * wiggleTime