예제 #1
0
        public DispatchController(
            BoundedInbox inbox,
            BoundedInbox chainControllerBox,
            BoundedInbox[] coinControllerBoxes,
            IOutpointHash hash,
            ILog log = null)
        {
            if (coinControllerBoxes.Length == 0)
            {
                throw new ArgumentException(nameof(coinControllerBoxes));
            }

            _queue = new ConcurrentQueue <ConnectionController>();

            _inbox = inbox;

            _chainControllerBox  = chainControllerBox;
            _coinControllerBoxes = coinControllerBoxes;
            _hash = hash;
            _log  = log;

            _mre = new ManualResetEvent(false);

            OnCoinMessageDispatched = new Action[_coinControllerBoxes.Length];

            _connections = new Dictionary <ClientId, ConnectionController>();
        }
예제 #2
0
        public CoinControllerTests()
        {
            var mockHash = new Mock <IOutpointHash>();

            mockHash.Setup(x => x.Hash(ref It.Ref <Outpoint> .IsAny))
            .Returns((Outpoint p) => BinaryPrimitives.ReadUInt64BigEndian(new ReadOnlySpan <byte>(p.TxId, 8)));

            _hash = mockHash.Object;
            _rand = new Random(2);
        }
예제 #3
0
        public CoinController(BoundedInbox inbox, BoundedInbox outbox, ICoinStore store, IOutpointHash hash,
                              ILog log = null, int shardIndex = -1)
        {
            _inbox      = inbox;
            _outbox     = outbox;
            _store      = store;
            _hash       = hash;
            _log        = log;
            _shardIndex = shardIndex;

            _pool = new SpanPool <byte>(PoolSizeInBytes);
            _mre  = new ManualResetEvent(false);
        }
예제 #4
0
 private static ICoinStore GetSozuTable(IPackStore store, IOutpointHash hash)
 {
     return(new SozuTable(store, hash));
 }
예제 #5
0
 public SozuTable(IPackStore store, IOutpointHash hash)
 {
     _store = store;
     _hash  = hash;
     _pool  = new SpanPool <byte>(SpanPoolCapacity);
 }