mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-07 11:32:20 +00:00
don't load everything on start
This commit is contained in:
parent
47c2ff43c2
commit
16621e41d4
@ -662,9 +662,6 @@ func New(newTxs chan Hashes, senders *SendersCache, db kv.RwDB) (*TxPool, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = restoreIsLocalHistory(db, localsHistory); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &TxPool{
|
||||
lock: &sync.RWMutex{},
|
||||
byHash: map[string]*metaTx{},
|
||||
@ -765,10 +762,7 @@ func (p *TxPool) IdHashIsLocal(hash []byte) bool {
|
||||
return txn.subPool&IsLocal != 0
|
||||
}
|
||||
func (p *TxPool) AddNewGoodPeer(peerID PeerID) { p.recentlyConnectedPeers.AddPeer(peerID) }
|
||||
|
||||
func (p *TxPool) Started() bool {
|
||||
return p.protocolBaseFee.Load() > 0
|
||||
}
|
||||
func (p *TxPool) Started() bool { return p.protocolBaseFee.Load() > 0 }
|
||||
|
||||
func (p *TxPool) OnNewTxs(ctx context.Context, coreDB kv.RoDB, newTxs TxSlots, senders *SendersCache) error {
|
||||
//t := time.Now()
|
||||
@ -1620,18 +1614,6 @@ func BroadcastLoop(ctx context.Context, db kv.RwDB, coreDB kv.RoDB, p *TxPool, s
|
||||
}
|
||||
}
|
||||
|
||||
func restoreIsLocalHistory(db kv.RwDB, localsHistory *simplelru.LRU) error {
|
||||
if db == nil {
|
||||
return nil
|
||||
}
|
||||
return db.View(context.Background(), func(tx kv.Tx) error {
|
||||
return tx.ForPrefix(kv.RecentLocalTransaction, nil, func(k, v []byte) error {
|
||||
localsHistory.Add(copyBytes(v), struct{}{})
|
||||
return nil
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func copyBytes(b []byte) (copiedBytes []byte) {
|
||||
copiedBytes = make([]byte, len(b))
|
||||
copy(copiedBytes, b)
|
||||
|
Loading…
Reference in New Issue
Block a user