diff options
author | Martin Holst Swende <martin@swende.se> | 2019-04-03 04:28:48 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-04-08 17:00:42 +0800 |
commit | af401d03a395c21fdb297edb687edf8af3470cb2 (patch) | |
tree | d2ee3476c9005ffe1aca7abbe7152765da0efe32 /consensus/clique | |
parent | 80a2a35bc3aaf208b5f91a1fb1d803975d4bb01c (diff) | |
download | go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar.gz go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar.bz2 go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar.lz go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar.xz go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar.zst go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.zip |
all: simplify timestamps to uint64 (#19372)
* all: simplify timestamps to uint64
* tests: update definitions
* clef, faucet, mobile: leftover uint64 fixups
* ethash: fix tests
* graphql: update schema for timestamp
* ethash: remove unused variable
Diffstat (limited to 'consensus/clique')
-rw-r--r-- | consensus/clique/clique.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index c79c30cae..a18782474 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -279,7 +279,7 @@ func (c *Clique) verifyHeader(chain consensus.ChainReader, header *types.Header, number := header.Number.Uint64() // Don't waste time checking blocks from the future - if header.Time.Cmp(big.NewInt(time.Now().Unix())) > 0 { + if header.Time > uint64(time.Now().Unix()) { return consensus.ErrFutureBlock } // Checkpoint blocks need to enforce zero beneficiary @@ -351,7 +351,7 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainReader, header *type if parent == nil || parent.Number.Uint64() != number-1 || parent.Hash() != header.ParentHash { return consensus.ErrUnknownAncestor } - if parent.Time.Uint64()+c.config.Period > header.Time.Uint64() { + if parent.Time+c.config.Period > header.Time { return ErrInvalidTimestamp } // Retrieve the snapshot needed to verify this header and cache it @@ -570,9 +570,9 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro if parent == nil { return consensus.ErrUnknownAncestor } - header.Time = new(big.Int).Add(parent.Time, new(big.Int).SetUint64(c.config.Period)) - if header.Time.Int64() < time.Now().Unix() { - header.Time = big.NewInt(time.Now().Unix()) + header.Time = parent.Time + c.config.Period + if header.Time < uint64(time.Now().Unix()) { + header.Time = uint64(time.Now().Unix()) } return nil } @@ -637,7 +637,7 @@ func (c *Clique) Seal(chain consensus.ChainReader, block *types.Block, results c } } // Sweet, the protocol permits us to sign the block, wait for our time - delay := time.Unix(header.Time.Int64(), 0).Sub(time.Now()) // nolint: gosimple + delay := time.Unix(int64(header.Time), 0).Sub(time.Now()) // nolint: gosimple 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 |