Skip to content

Commit

Permalink
Merge pull request #2313 from planetarium/fix-stagepolicy
Browse files Browse the repository at this point in the history
use concurrent dictionary in stagepolicy
  • Loading branch information
area363 authored Dec 19, 2023
2 parents 0237a58 + b7f69a1 commit b606e21
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Lib9c.Policy/NCStagePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class NCStagePolicy : IStagePolicy
private readonly VolatileStagePolicy _impl;
private readonly ConcurrentDictionary<Address, SortedList<Transaction, TxId>> _txs;
private readonly int _quotaPerSigner;
private readonly Dictionary<Address, int> _quotaPerSignerList;
private readonly ConcurrentDictionary<Address, int> _quotaPerSignerList;
private IAccessControlService? _accessControlService;

public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner, IAccessControlService? accessControlService = null)
Expand All @@ -32,7 +32,7 @@ public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner, IAccessControlServ
? new VolatileStagePolicy()
: new VolatileStagePolicy(txLifeTime);

_quotaPerSignerList = new Dictionary<Address, int>();
_quotaPerSignerList = new ConcurrentDictionary<Address, int>();
_accessControlService = accessControlService;
}

Expand All @@ -52,7 +52,7 @@ public IEnumerable<Transaction> Iterate(BlockChain blockChain, bool filtered = t
{
if (filtered)
{
var txsPerSigner = new Dictionary<Address, SortedSet<Transaction>>();
var txsPerSigner = new ConcurrentDictionary<Address, SortedSet<Transaction>>();
foreach (Transaction tx in _impl.Iterate(blockChain, filtered))
{
if (!txsPerSigner.TryGetValue(tx.Signer, out var s))
Expand Down

0 comments on commit b606e21

Please sign in to comment.