diff --git a/Lib9c.Policy/NCStagePolicy.cs b/Lib9c.Policy/NCStagePolicy.cs
index 0dbd00c1f5..13b77bdf60 100644
--- a/Lib9c.Policy/NCStagePolicy.cs
+++ b/Lib9c.Policy/NCStagePolicy.cs
@@ -15,6 +15,7 @@ public class NCStagePolicy : IStagePolicy
private readonly VolatileStagePolicy _impl;
private readonly ConcurrentDictionary
> _txs;
private readonly int _quotaPerSigner;
+ private readonly Dictionary _quotaPerSignerList;
private IAccessControlService? _accessControlService;
public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner, IAccessControlService? accessControlService = null)
@@ -31,6 +32,7 @@ public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner, IAccessControlServ
? new VolatileStagePolicy()
: new VolatileStagePolicy(txLifeTime);
+ _quotaPerSignerList = new Dictionary();
_accessControlService = accessControlService;
}
@@ -61,10 +63,10 @@ public IEnumerable Iterate(BlockChain blockChain, bool filtered = t
s.Add(tx);
int txQuotaPerSigner = _quotaPerSigner;
- // update txQuotaPerSigner if ACS returns a value for the signer.
- if (_accessControlService?.GetTxQuota(tx.Signer) is { } acsTxQuota)
+ // update txQuotaPerSigner if signer is in the list
+ if (_quotaPerSignerList.TryGetValue(tx.Signer, out int signerQuota))
{
- txQuotaPerSigner = acsTxQuota;
+ txQuotaPerSigner = signerQuota;
}
@@ -86,10 +88,14 @@ public IEnumerable Iterate(BlockChain blockChain, bool filtered = t
public bool Stage(BlockChain blockChain, Transaction transaction)
{
- if (_accessControlService?.GetTxQuota(transaction.Signer) is { } acsTxQuota
- && acsTxQuota == 0)
+ if (_accessControlService?.GetTxQuota(transaction.Signer) is { } acsTxQuota)
{
- return false;
+ _quotaPerSignerList[transaction.Signer] = acsTxQuota;
+
+ if (acsTxQuota == 0)
+ {
+ return false;
+ }
}
var deniedTxs = new[]