Skip to content

Commit

Permalink
Remove write lock in BlockChain<T>.StageTransactions()
Browse files Browse the repository at this point in the history
  • Loading branch information
longfin committed Apr 25, 2019
1 parent a0ae57f commit 8d5f8a1
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions Libplanet/Blockchain/BlockChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,23 +284,14 @@ public void Append(Block<T> block) => Append(

public void StageTransactions(ISet<Transaction<T>> txs)
{
try
foreach (Transaction<T> tx in txs)
{
_rwlock.EnterWriteLock();

foreach (Transaction<T> tx in txs)
{
Transactions[tx.Id] = tx;
}

Store.StageTransactionIds(
txs.Select(tx => tx.Id).ToImmutableHashSet()
);
}
finally
{
_rwlock.ExitWriteLock();
Transactions[tx.Id] = tx;
}

Store.StageTransactionIds(
txs.Select(tx => tx.Id).ToImmutableHashSet()
);
}

public Block<T> MineBlock(
Expand Down

0 comments on commit 8d5f8a1

Please sign in to comment.