Compare commits

..

1 Commits
v0.5.3 ... dev

Author SHA1 Message Date
Solovyov1796
80208ed9b7
Merge pull request #122 from 0glabs/testnet/v0.5.x
merge Testnet/v0.5.x to dev
2025-03-27 14:15:26 +08:00

View File

@ -2,9 +2,7 @@ package app
import (
"context"
"math/rand"
"sync"
"time"
"fmt"
"math"
@ -29,9 +27,6 @@ var (
errMempoolTooManyTxs = errors.New("tx sender has too many txs in mempool")
errMempoolIsFull = errors.New("mempool is full")
errTxInMempool = errors.New("tx already in mempool")
staticSrc = rand.NewSource(time.Now().UnixNano())
staticRng = rand.New(staticSrc)
)
// PriorityNonceMempool is a mempool implementation that stores txs
@ -165,8 +160,6 @@ func NewPriorityMempool(opts ...PriorityNonceMempoolOption) *PriorityNonceMempoo
txRecord: make(map[txMeta]struct{}),
}
mp.priorityIndex.SetRandSource(staticSrc)
for _, opt := range opts {
opt(mp)
}
@ -225,7 +218,6 @@ func (mp *PriorityNonceMempool) Insert(ctx context.Context, tx sdk.Tx) error {
senderIndex = skiplist.New(skiplist.LessThanFunc(func(a, b any) int {
return skiplist.Uint64.Compare(b.(txMeta).nonce, a.(txMeta).nonce)
}))
senderIndex.SetRandSource(staticRng)
// initialize sender index if not found
mp.senderIndices[txInfo.Sender] = senderIndex
@ -314,7 +306,7 @@ func (mp *PriorityNonceMempool) doInsert(newKey txMeta, tx sdk.Tx, incrCnt bool)
senderIndex = skiplist.New(skiplist.LessThanFunc(func(a, b any) int {
return skiplist.Uint64.Compare(b.(txMeta).nonce, a.(txMeta).nonce)
}))
senderIndex.SetRandSource(staticRng)
// initialize sender index if not found
mp.senderIndices[newKey.sender] = senderIndex
}