Skip to content

Commit

Permalink
Removed unnecessary read lock
Browse files Browse the repository at this point in the history
  • Loading branch information
greymistcube committed Sep 6, 2024
1 parent 443e1b6 commit e8567d3
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/Libplanet/Blockchain/BlockChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1189,28 +1189,19 @@ internal void AppendStateRootHashPreceded(
/// <see langword="null"/>.</returns>
internal BlockHash? FindBranchpoint(BlockLocator locator)
{
try
if (ContainsBlock(locator.Hash))
{
_rwlock.EnterReadLock();

if (ContainsBlock(locator.Hash))
{
_logger.Debug(
"Found a branchpoint with locator [{LocatorHead}]: {Hash}",
locator.Hash,
locator.Hash);
return locator.Hash;
}

_logger.Debug(
"Failed to find a branchpoint locator [{LocatorHead}]",
"Found a branchpoint with locator [{LocatorHead}]: {Hash}",
locator.Hash,
locator.Hash);
return null;
}
finally
{
_rwlock.ExitReadLock();
return locator.Hash;
}

_logger.Debug(
"Failed to find a branchpoint locator [{LocatorHead}]",
locator.Hash);
return null;
}

/// <summary>
Expand Down

0 comments on commit e8567d3

Please sign in to comment.