core: reset txpool on sethead (#26392)
This change sends a HeadChainEvent when SetHead is invoked. The txpool will then reset the txnoncer on receiving the event.
This commit is contained in:
parent
c87f321b8f
commit
db82ea2ee3
@ -532,9 +532,13 @@ func (bc *BlockChain) loadLastState() error {
|
|||||||
// was fast synced or full synced and in which state, the method will try to
|
// was fast synced or full synced and in which state, the method will try to
|
||||||
// delete minimal data from disk whilst retaining chain consistency.
|
// delete minimal data from disk whilst retaining chain consistency.
|
||||||
func (bc *BlockChain) SetHead(head uint64) error {
|
func (bc *BlockChain) SetHead(head uint64) error {
|
||||||
_, err := bc.setHeadBeyondRoot(head, common.Hash{}, false)
|
if _, err := bc.setHeadBeyondRoot(head, common.Hash{}, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// Send chain head event to update the transaction pool
|
||||||
|
bc.chainHeadFeed.Send(ChainHeadEvent{Block: bc.CurrentBlock()})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// SetFinalized sets the finalized block.
|
// SetFinalized sets the finalized block.
|
||||||
func (bc *BlockChain) SetFinalized(block *types.Block) {
|
func (bc *BlockChain) SetFinalized(block *types.Block) {
|
||||||
|
@ -118,9 +118,6 @@ func TestGethClient(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
"TestGetNodeInfo",
|
"TestGetNodeInfo",
|
||||||
func(t *testing.T) { testGetNodeInfo(t, client) },
|
func(t *testing.T) { testGetNodeInfo(t, client) },
|
||||||
}, {
|
|
||||||
"TestSetHead",
|
|
||||||
func(t *testing.T) { testSetHead(t, client) },
|
|
||||||
}, {
|
}, {
|
||||||
"TestSubscribePendingTxHashes",
|
"TestSubscribePendingTxHashes",
|
||||||
func(t *testing.T) { testSubscribePendingTransactions(t, client) },
|
func(t *testing.T) { testSubscribePendingTransactions(t, client) },
|
||||||
@ -138,6 +135,9 @@ func TestGethClient(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"TestAccessList",
|
"TestAccessList",
|
||||||
func(t *testing.T) { testAccessList(t, client) },
|
func(t *testing.T) { testAccessList(t, client) },
|
||||||
|
}, {
|
||||||
|
"TestSetHead",
|
||||||
|
func(t *testing.T) { testSetHead(t, client) },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user