Skip to content

Commit

Permalink
Move dispose after await.
Browse files Browse the repository at this point in the history
  • Loading branch information
damian-orzechowski committed Dec 9, 2024
1 parent a10180b commit 589baec
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public async Task Dispatch(PeerInfo peerInfo, StateSyncBatch batch, Cancellation
ISyncPeer peer = peerInfo.SyncPeer;
Task<IOwnedReadOnlyList<byte[]>> task = null;
HashList? hashList = null;
GetTrieNodesRequest? getTrieNodesRequest = null;
// Use GETNODEDATA if possible. Firstly via dedicated NODEDATA protocol
if (peer.TryGetSatelliteProtocol(Protocol.NodeData, out INodeDataPeer nodeDataHandler))
{
Expand All @@ -65,8 +66,8 @@ public async Task Dispatch(PeerInfo peerInfo, StateSyncBatch batch, Cancellation
else
{
if (Logger.IsTrace) Logger.Trace($"Requested TrieNodes via SnapProtocol from peer {peer}");
using GetTrieNodesRequest request = GetGroupedRequest(batch);
task = snapHandler.GetTrieNodes(request, cancellationToken);
getTrieNodesRequest = GetGroupedRequest(batch);
task = snapHandler.GetTrieNodes(getTrieNodesRequest, cancellationToken);
}
}

Expand All @@ -80,6 +81,7 @@ public async Task Dispatch(PeerInfo peerInfo, StateSyncBatch batch, Cancellation
batch.Responses = await task;

if (hashList is not null) HashList.Return(hashList);
getTrieNodesRequest?.Dispose();
}
catch (Exception e)
{
Expand Down

0 comments on commit 589baec

Please sign in to comment.