Skip to content

Commit

Permalink
Write lock on whole PrepareRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
ak88 committed Dec 20, 2023
1 parent 2f0366b commit 51b2871
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private bool HasDependencyToProcess

public override Task<HeadersSyncBatch?> PrepareRequest(CancellationToken cancellationToken = default)
{
_resetLock.EnterReadLock();
_resetLock.EnterWriteLock();
try
{
do
Expand All @@ -320,23 +320,19 @@ private bool HasDependencyToProcess

if (batch is not null)
{
lock (_handlerLock)
{
_sent.Add(batch);
}
_sent.Add(batch);
if (batch.StartNumber >= (LowestInsertedBlockHeader?.Number ?? 0) - FastBlocksPriorities.ForHeaders)
{
batch.Prioritized = true;
}

LogStateOnPrepare();
}

return Task.FromResult(batch);
}
finally
{
_resetLock.ExitReadLock();
_resetLock.ExitWriteLock();
}
}

Expand Down

0 comments on commit 51b2871

Please sign in to comment.