mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-01 00:31:21 +00:00
save
This commit is contained in:
parent
ca4595a051
commit
f74fc193ba
@ -266,6 +266,10 @@ func (f *Fetch) handleInboundMessage(ctx context.Context, req *sentry.InboundMes
|
||||
return err
|
||||
}
|
||||
case sentry.MessageId_POOLED_TRANSACTIONS_65, sentry.MessageId_POOLED_TRANSACTIONS_66:
|
||||
if !f.pool.Started() {
|
||||
return nil
|
||||
}
|
||||
|
||||
parseCtx := NewTxParseContext()
|
||||
txs := TxSlots{}
|
||||
if req.Id == sentry.MessageId_GET_POOLED_TRANSACTIONS_66 {
|
||||
|
@ -33,6 +33,9 @@ var _ Pool = &PoolMock{}
|
||||
// OnNewBlockFunc: func(db kv.Tx, stateChanges map[string]senderInfo, unwindTxs TxSlots, minedTxs TxSlots, protocolBaseFee uint64, pendingBaseFee uint64, blockHeight uint64) error {
|
||||
// panic("mock out the OnNewBlock method")
|
||||
// },
|
||||
// StartedFunc: func() bool {
|
||||
// panic("mock out the Started method")
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// // use mockedPool in code that requires Pool
|
||||
@ -55,6 +58,9 @@ type PoolMock struct {
|
||||
// OnNewBlockFunc mocks the OnNewBlock method.
|
||||
OnNewBlockFunc func(db kv.Tx, stateChanges map[string]senderInfo, unwindTxs TxSlots, minedTxs TxSlots, protocolBaseFee uint64, pendingBaseFee uint64, blockHeight uint64) error
|
||||
|
||||
// StartedFunc mocks the Started method.
|
||||
StartedFunc func() bool
|
||||
|
||||
// calls tracks calls to the methods.
|
||||
calls struct {
|
||||
// Add holds details about calls to the Add method.
|
||||
@ -96,12 +102,16 @@ type PoolMock struct {
|
||||
// BlockHeight is the blockHeight argument value.
|
||||
BlockHeight uint64
|
||||
}
|
||||
// Started holds details about calls to the Started method.
|
||||
Started []struct {
|
||||
}
|
||||
}
|
||||
lockAdd sync.RWMutex
|
||||
lockAddNewGoodPeer sync.RWMutex
|
||||
lockGetRlp sync.RWMutex
|
||||
lockIdHashKnown sync.RWMutex
|
||||
lockOnNewBlock sync.RWMutex
|
||||
lockStarted sync.RWMutex
|
||||
}
|
||||
|
||||
// Add calls AddFunc.
|
||||
@ -298,3 +308,32 @@ func (mock *PoolMock) OnNewBlockCalls() []struct {
|
||||
mock.lockOnNewBlock.RUnlock()
|
||||
return calls
|
||||
}
|
||||
|
||||
// Started calls StartedFunc.
|
||||
func (mock *PoolMock) Started() bool {
|
||||
callInfo := struct {
|
||||
}{}
|
||||
mock.lockStarted.Lock()
|
||||
mock.calls.Started = append(mock.calls.Started, callInfo)
|
||||
mock.lockStarted.Unlock()
|
||||
if mock.StartedFunc == nil {
|
||||
var (
|
||||
bOut bool
|
||||
)
|
||||
return bOut
|
||||
}
|
||||
return mock.StartedFunc()
|
||||
}
|
||||
|
||||
// StartedCalls gets all the calls that were made to Started.
|
||||
// Check the length with:
|
||||
// len(mockedPool.StartedCalls())
|
||||
func (mock *PoolMock) StartedCalls() []struct {
|
||||
} {
|
||||
var calls []struct {
|
||||
}
|
||||
mock.lockStarted.RLock()
|
||||
calls = mock.calls.Started
|
||||
mock.lockStarted.RUnlock()
|
||||
return calls
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import (
|
||||
type Pool interface {
|
||||
// IdHashKnown check whether transaction with given Id hash is known to the pool
|
||||
IdHashKnown(hash []byte) bool
|
||||
Started() bool
|
||||
GetRlp(hash []byte) []byte
|
||||
Add(db kv.Tx, newTxs TxSlots) error
|
||||
OnNewBlock(db kv.Tx, stateChanges map[string]senderInfo, unwindTxs, minedTxs TxSlots, protocolBaseFee, pendingBaseFee, blockHeight uint64) error
|
||||
@ -332,6 +333,7 @@ func (p *TxPool) setBaseFee(protocolBaseFee, pendingBaseFee uint64) (uint64, uin
|
||||
}
|
||||
|
||||
func (p *TxPool) OnNewBlock(coreDB kv.Tx, stateChanges map[string]senderInfo, unwindTxs, minedTxs TxSlots, protocolBaseFee, pendingBaseFee, blockHeight uint64) error {
|
||||
log.Debug("[txpool.onNewBlock]", "unwinded", len(unwindTxs.txs), "mined", len(minedTxs.txs), "protocolBaseFee", protocolBaseFee, "blockHeight", blockHeight)
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
if err := unwindTxs.Valid(); err != nil {
|
||||
@ -356,6 +358,8 @@ func (p *TxPool) OnNewBlock(coreDB kv.Tx, stateChanges map[string]senderInfo, un
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug("[txpool.onNewBlock]", "senderInfo", len(p.senderInfo))
|
||||
|
||||
if err := onNewBlock(p.senderInfo, unwindTxs, minedTxs.txs, protocolBaseFee, pendingBaseFee, p.pending, p.baseFee, p.queued, p.byHash, p.localsHistory); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user