mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-04-04 15:55:23 +00:00
Compare commits
No commits in common. "8d5e81154a2b5ff32aa5451bb6f9ae20a8914184" and "96926b4cbf25f9a3fb4935359a8b53a3ae798b21" have entirely different histories.
8d5e81154a
...
96926b4cbf
@ -2,9 +2,7 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"math/rand"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
@ -29,9 +27,6 @@ var (
|
|||||||
errMempoolTooManyTxs = errors.New("tx sender has too many txs in mempool")
|
errMempoolTooManyTxs = errors.New("tx sender has too many txs in mempool")
|
||||||
errMempoolIsFull = errors.New("mempool is full")
|
errMempoolIsFull = errors.New("mempool is full")
|
||||||
errTxInMempool = errors.New("tx already in mempool")
|
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
|
// PriorityNonceMempool is a mempool implementation that stores txs
|
||||||
@ -165,8 +160,6 @@ func NewPriorityMempool(opts ...PriorityNonceMempoolOption) *PriorityNonceMempoo
|
|||||||
txRecord: make(map[txMeta]struct{}),
|
txRecord: make(map[txMeta]struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
mp.priorityIndex.SetRandSource(staticSrc)
|
|
||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(mp)
|
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 {
|
senderIndex = skiplist.New(skiplist.LessThanFunc(func(a, b any) int {
|
||||||
return skiplist.Uint64.Compare(b.(txMeta).nonce, a.(txMeta).nonce)
|
return skiplist.Uint64.Compare(b.(txMeta).nonce, a.(txMeta).nonce)
|
||||||
}))
|
}))
|
||||||
senderIndex.SetRandSource(staticRng)
|
|
||||||
|
|
||||||
// initialize sender index if not found
|
// initialize sender index if not found
|
||||||
mp.senderIndices[txInfo.Sender] = senderIndex
|
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 {
|
senderIndex = skiplist.New(skiplist.LessThanFunc(func(a, b any) int {
|
||||||
return skiplist.Uint64.Compare(b.(txMeta).nonce, a.(txMeta).nonce)
|
return skiplist.Uint64.Compare(b.(txMeta).nonce, a.(txMeta).nonce)
|
||||||
}))
|
}))
|
||||||
senderIndex.SetRandSource(staticRng)
|
|
||||||
// initialize sender index if not found
|
// initialize sender index if not found
|
||||||
mp.senderIndices[newKey.sender] = senderIndex
|
mp.senderIndices[newKey.sender] = senderIndex
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user