Skip to content

Commit

Permalink
Merge pull request #2168 from planetarium/feat/disallowed-accounts
Browse files Browse the repository at this point in the history
[Feature] Add access control service interface
  • Loading branch information
Atralupus authored and area363 committed Oct 25, 2023
1 parent 538afea commit fdae923
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
9 changes: 9 additions & 0 deletions Lib9c.Policy/AccessControlService/IAccessControlService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Libplanet.Crypto;

namespace Nekoyume.Blockchain
{
public interface IAccessControlService
{
public bool IsAccessDenied(Address address);
}
}
30 changes: 5 additions & 25 deletions Lib9c.Policy/NCStagePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,9 @@ public class NCStagePolicy : IStagePolicy
private readonly VolatileStagePolicy _impl;
private readonly ConcurrentDictionary<Address, SortedList<Transaction, TxId>> _txs;
private readonly int _quotaPerSigner;
private IAccessControlService? _accessControlService;

private static readonly ImmutableHashSet<Address> _bannedAccounts = new[]
{
new Address("de96aa7702a7a1fd18ee0f84a5a0c7a2c28ec840"),
new Address("153281c93274bEB9726A03C33d3F19a8D78ad805"),
new Address("7035AA8B7F9fB5db026fb843CbB21C03dd278502"),
new Address("52393Ea89DF0E58152cbFE673d415159aa7B9dBd"),
new Address("2D1Db6dBF1a013D648Efd16d85B4079dCF88B4CC"),
new Address("dE30E00917B583305f14aD21Eafc70f1b183b779"),
new Address("B892052f1E10bf700143dd9bEcd81E31CD7f7095"),

new Address("C0a90FC489738A1153F793A3272A91913aF3956b"),
new Address("b8D7bD4394980dcc2579019C39bA6b41cb6424E1"),
new Address("555221D1CEA826C55929b8A559CA929574f7C6B3"),
new Address("B892052f1E10bf700143dd9bEcd81E31CD7f7095"),
// v100351
new Address("0xd7e1b90dea34108fb2d3a6ac7dbf3f33bae2c77d"),
// v200060
new Address("3FadCb61827E4B70eBAFAF61E2c02fc2711FBb5A"),
new Address("7655122899Ccd2cC87B38A35D7158c9516504119"),
new Address("3165fda4aAE0362EFFd8Ae6e8674AA49381b4485"),
new Address("CAFC88175f88973d01e6A9479b31eC0beb020b8a"),
}.ToImmutableHashSet();

public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner)
public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner, IAccessControlService? accessControlService = null)
{
if (quotaPerSigner < 1)
{
Expand All @@ -52,6 +30,8 @@ public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner)
_impl = (txLifeTime == default)
? new VolatileStagePolicy()
: new VolatileStagePolicy(txLifeTime);

_accessControlService = accessControlService;
}

public Transaction Get(BlockChain blockChain, TxId id, bool filtered = true)
Expand Down Expand Up @@ -97,7 +77,7 @@ public IEnumerable<Transaction> Iterate(BlockChain blockChain, bool filtered = t

public bool Stage(BlockChain blockChain, Transaction transaction)
{
if (_bannedAccounts.Contains(transaction.Signer))
if (_accessControlService != null && _accessControlService.IsAccessDenied(transaction.Signer))
{
return false;
}
Expand Down

0 comments on commit fdae923

Please sign in to comment.