Merge pull request #706 from gzliudan/fix-s1024

all: fix staticcheck warning S1024: not use x.Sub(time.Now())
This commit is contained in:
Daniel Liu 2024-10-31 10:59:52 +08:00 committed by GitHub
commit 40ae9e3ffb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View file

@ -517,7 +517,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
// Send an error if too frequent funding, othewise a success
if !fund {
if err = sendError(wsconn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(timeout.Sub(time.Now())))); err != nil { // nolint: gosimple
if err = sendError(wsconn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(time.Until(timeout)))); err != nil {
log.Warn("Failed to send funding error to client", "err", err)
return
}

View file

@ -644,7 +644,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()) // nolint: gosimple
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

View file

@ -679,7 +679,7 @@ func (f *Fetcher) insert(peer string, block *types.Block) {
go f.broadcastBlock(block, true)
}
case consensus.ErrFutureBlock:
delay := time.Unix(block.Time().Int64(), 0).Sub(time.Now()) // nolint: gosimple
delay := time.Until(time.Unix(block.Time().Int64(), 0))
log.Info("Receive future block", "number", block.NumberU64(), "hash", block.Hash().Hex(), "delay", delay)
time.Sleep(delay)
goto again