pool constructor

This commit is contained in:
alex.sharov 2021-08-04 11:53:30 +07:00
parent 9a9d017866
commit 3204f70409

View File

@ -99,8 +99,7 @@ func (i *nonce2TxItem) Less(than btree.Item) bool {
// TxPool - holds all pool-related data structures and lock-based tiny methods
// most of logic implemented by pure tests-friendly functions
type TxPool struct {
lock *sync.RWMutex
logger log.Logger //nolint
lock *sync.RWMutex
protocolBaseFee atomic.Uint64
blockBaseFee atomic.Uint64
@ -117,6 +116,20 @@ type TxPool struct {
//lastTxPropagationTimestamp time.Time
}
func New() *TxPool {
localsHistory, _ := lru.New(1024)
return &TxPool{
lock: &sync.RWMutex{},
senderInfo: map[uint64]SenderInfo{},
byHash: map[string]*MetaTx{},
localsHistory: localsHistory,
recentlyConnectedPeers: &recentlyConnectedPeers{},
pending: NewSubPool(),
baseFee: NewSubPool(),
queued: NewSubPool(),
}
}
func (p *TxPool) GetRlp(hash []byte) []byte {
p.lock.RLock()
defer p.lock.RUnlock()
@ -557,12 +570,6 @@ type PoolImpl struct {
logger log.Logger
}
func NewPool() *PoolImpl {
return &PoolImpl{
recentlyConnectedPeers: &recentlyConnectedPeers{},
}
}
// Loop - does:
// send pending byHash to p2p:
// - new byHash