@@ -15,7 +15,7 @@ public class NCStagePolicy : IStagePolicy
1515 private readonly VolatileStagePolicy _impl ;
1616 private readonly ConcurrentDictionary < Address , SortedList < Transaction , TxId > > _txs ;
1717 private readonly int _quotaPerSigner ;
18- private readonly Dictionary < Address , int > _quotaPerSignerList ;
18+ private readonly ConcurrentDictionary < Address , int > _quotaPerSignerList ;
1919 private IAccessControlService ? _accessControlService ;
2020
2121 public NCStagePolicy ( TimeSpan txLifeTime , int quotaPerSigner , IAccessControlService ? accessControlService = null )
@@ -32,7 +32,7 @@ public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner, IAccessControlServ
3232 ? new VolatileStagePolicy ( )
3333 : new VolatileStagePolicy ( txLifeTime ) ;
3434
35- _quotaPerSignerList = new Dictionary < Address , int > ( ) ;
35+ _quotaPerSignerList = new ConcurrentDictionary < Address , int > ( ) ;
3636 _accessControlService = accessControlService ;
3737 }
3838
@@ -52,7 +52,7 @@ public IEnumerable<Transaction> Iterate(BlockChain blockChain, bool filtered = t
5252 {
5353 if ( filtered )
5454 {
55- var txsPerSigner = new Dictionary < Address , SortedSet < Transaction > > ( ) ;
55+ var txsPerSigner = new ConcurrentDictionary < Address , SortedSet < Transaction > > ( ) ;
5656 foreach ( Transaction tx in _impl . Iterate ( blockChain , filtered ) )
5757 {
5858 if ( ! txsPerSigner . TryGetValue ( tx . Signer , out var s ) )
@@ -88,29 +88,39 @@ public IEnumerable<Transaction> Iterate(BlockChain blockChain, bool filtered = t
8888
8989 public bool Stage ( BlockChain blockChain , Transaction transaction )
9090 {
91- if ( _accessControlService ? . GetTxQuota ( transaction . Signer ) is { } acsTxQuota )
91+ try
9292 {
93- _quotaPerSignerList [ transaction . Signer ] = acsTxQuota ;
93+ if ( _accessControlService ? . GetTxQuota ( transaction . Signer ) is { } acsTxQuota )
94+ {
95+ _quotaPerSignerList [ transaction . Signer ] = acsTxQuota ;
96+
97+ if ( acsTxQuota == 0 )
98+ {
99+ return false ;
100+ }
101+ }
94102
95- if ( acsTxQuota == 0 )
103+ var deniedTxs = new [ ]
104+ {
105+ // CreatePledge Transaction with 50000 addresses
106+ TxId . FromHex (
107+ "300826da62b595d8cd663dadf04995a7411534d1cdc17dac75ce88754472f774" ) ,
108+ // CreatePledge Transaction with 5000 addresses
109+ TxId . FromHex (
110+ "210d1374d8f068de657de6b991e63888da9cadbc68e505ac917b35568b5340f8" ) ,
111+ } ;
112+ if ( deniedTxs . Contains ( transaction . Id ) )
96113 {
97114 return false ;
98115 }
99- }
100116
101- var deniedTxs = new [ ]
102- {
103- // CreatePledge Transaction with 50000 addresses
104- TxId . FromHex ( "300826da62b595d8cd663dadf04995a7411534d1cdc17dac75ce88754472f774" ) ,
105- // CreatePledge Transaction with 5000 addresses
106- TxId . FromHex ( "210d1374d8f068de657de6b991e63888da9cadbc68e505ac917b35568b5340f8" ) ,
107- } ;
108- if ( deniedTxs . Contains ( transaction . Id ) )
117+ return _impl . Stage ( blockChain , transaction ) ;
118+ }
119+ catch ( Exception ex )
109120 {
110- return false ;
121+ Console . WriteLine ( "[NCStagePolicy-ACS] {0} {1}" , ex . Message , ex . StackTrace ) ;
122+ return _impl . Stage ( blockChain , transaction ) ;
111123 }
112-
113- return _impl . Stage ( blockChain , transaction ) ;
114124 }
115125
116126 public bool Unstage ( BlockChain blockChain , TxId id )
0 commit comments