pool constructor

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

View File

@ -100,7 +100,6 @@ func (i *nonce2TxItem) Less(than btree.Item) bool {
// most of logic implemented by pure tests-friendly functions // most of logic implemented by pure tests-friendly functions
type TxPool struct { type TxPool struct {
lock *sync.RWMutex lock *sync.RWMutex
logger log.Logger //nolint
protocolBaseFee atomic.Uint64 protocolBaseFee atomic.Uint64
blockBaseFee atomic.Uint64 blockBaseFee atomic.Uint64
@ -117,6 +116,20 @@ type TxPool struct {
//lastTxPropagationTimestamp time.Time //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 { func (p *TxPool) GetRlp(hash []byte) []byte {
p.lock.RLock() p.lock.RLock()
defer p.lock.RUnlock() defer p.lock.RUnlock()
@ -557,12 +570,6 @@ type PoolImpl struct {
logger log.Logger logger log.Logger
} }
func NewPool() *PoolImpl {
return &PoolImpl{
recentlyConnectedPeers: &recentlyConnectedPeers{},
}
}
// Loop - does: // Loop - does:
// send pending byHash to p2p: // send pending byHash to p2p:
// - new byHash // - new byHash