Skip to content

Commit

Permalink
test stagepolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
area363 committed Jul 25, 2023
1 parent ae04edd commit 8ba2414
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Lib9c.Policy/NCStagePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class NCStagePolicy : IStagePolicy
private readonly ConcurrentDictionary<Address, SortedList<Transaction, TxId>> _txs;
private readonly int _quotaPerSigner;

private ImmutableHashSet<Address> _bannedAccounts = new[]
public ImmutableHashSet<Address> BannedAccounts = new[]
{
new Address("de96aa7702a7a1fd18ee0f84a5a0c7a2c28ec840"),
new Address("153281c93274bEB9726A03C33d3F19a8D78ad805"),
Expand Down Expand Up @@ -87,7 +87,7 @@ public IEnumerable<Transaction> Iterate(BlockChain blockChain, bool filtered = t
{
Log.Debug("Adding {signer} to banned accounts for 30 minutes", tx.Signer);
_bannedAccountTracker.Add(tx.Signer, DateTimeOffset.Now);
_bannedAccounts = _bannedAccounts.Add(tx.Signer);
BannedAccounts = BannedAccounts.Add(tx.Signer);
}
}
}
Expand All @@ -104,15 +104,15 @@ public IEnumerable<Transaction> Iterate(BlockChain blockChain, bool filtered = t

public bool Stage(BlockChain blockChain, Transaction transaction)
{
if (_bannedAccounts.Contains(transaction.Signer))
if (BannedAccounts.Contains(transaction.Signer))
{
if (_bannedAccountTracker.ContainsKey(transaction.Signer))
{
if ((DateTimeOffset.Now - _bannedAccountTracker[transaction.Signer]).Minutes >= 30)
{
Log.Debug("Removing {signer} from banned accounts after 30 minutes", transaction.Signer);
_bannedAccountTracker.Remove(transaction.Signer);
_bannedAccounts = _bannedAccounts.Remove(transaction.Signer);
BannedAccounts = BannedAccounts.Remove(transaction.Signer);
}
}

Expand Down

0 comments on commit 8ba2414

Please sign in to comment.