mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/fetcher: use time.duration
This commit is contained in:
parent
930dcba1fd
commit
be07a00a26
2 changed files with 3 additions and 3 deletions
|
|
@ -61,7 +61,7 @@ const (
|
|||
maxTxUnderpricedSetSize = 32768
|
||||
|
||||
// maxTxUnderpricedTimeout is the max time a transaction should be stuck in the underpriced set.
|
||||
maxTxUnderpricedTimeout = int64(5 * time.Minute)
|
||||
maxTxUnderpricedTimeout = 5 * time.Minute
|
||||
|
||||
// txArriveTimeout is the time allowance before an announced transaction is
|
||||
// explicitly requested.
|
||||
|
|
@ -284,7 +284,7 @@ func (f *TxFetcher) Notify(peer string, types []byte, sizes []uint32, hashes []c
|
|||
// isKnownUnderpriced reports whether a transaction hash was recently found to be underpriced.
|
||||
func (f *TxFetcher) isKnownUnderpriced(hash common.Hash) bool {
|
||||
prevTime, ok := f.underpriced.Peek(hash)
|
||||
if ok && prevTime+maxTxUnderpricedTimeout < time.Now().UnixNano() {
|
||||
if ok && prevTime < time.Now().Add(-maxTxUnderpricedTimeout).UnixNano() {
|
||||
f.underpriced.Remove(hash)
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2009,7 +2009,7 @@ func TestTransactionForgotten(t *testing.T) {
|
|||
)
|
||||
go fetcher.loop()
|
||||
tx1 := types.NewTransaction(0, common.Address{}, common.Big0, 0, common.Big0, nil)
|
||||
tx1.SetTime(time.Now().Add(-5 * time.Minute))
|
||||
tx1.SetTime(time.Now().Add(-maxTxUnderpricedTimeout))
|
||||
tx2 := types.NewTransaction(1, common.Address{}, common.Big0, 0, common.Big0, nil)
|
||||
if fetcher.isKnownUnderpriced(tx1.Hash()) {
|
||||
t.Fatal("unknown hash can not be underpriced")
|
||||
|
|
|
|||
Loading…
Reference in a new issue