Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/Nethermind/Nethermind.TxPool/TxPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ private void OnRemovedTx(object? sender, SortedPool<ValueHash256, Transaction, A
}
private void OnHeadChange(object? sender, BlockReplacementEventArgs e)
{
if (_headInfo.IsSyncing) return;
if (_headInfo.IsSyncing)
{
DisposeBlockAccountChanges(e.Block);
return;
}

try
{
Expand Down Expand Up @@ -263,8 +267,8 @@ private async Task ProcessNewHeadLoop()
// Sequential block, just remove changed accounts from cache
_accountCache.RemoveAccounts(accountChanges);
}
args.Block.AccountChanges = null;
accountChanges?.Dispose();

DisposeBlockAccountChanges(args.Block);

_lastBlockNumber = args.Block.Number;
_lastBlockHash = args.Block.Hash;
Expand Down Expand Up @@ -1015,6 +1019,15 @@ private static void WriteTxPoolReport(in ILogger logger)
------------------------------------------------
");
}

// Cleanup ArrayPoolList AccountChanges as they are not used anywhere else
private static void DisposeBlockAccountChanges(Block block)
{
if (block.AccountChanges is null) return;

block.AccountChanges.Dispose();
block.AccountChanges = null;
}
}
}