示例#1
0
 public LightningStore(string pathToFolder, string dbName)
 {
     _env              = new LightningEnvironment(pathToFolder);
     _dbName           = dbName;
     _env.MaxDatabases = 1;
     _env.Open();
     _pool = new SpanPool <byte>(PoolSizeInBytes);
 }
示例#2
0
 /// <summary>
 /// Check capacity of SpanPool and allocate a new one if capacity is
 /// not sufficient.
 /// </summary>
 private Span <byte> GetSpan(int length)
 {
     if (_pool.Capacity < length)
     {
         _pool = new SpanPool <byte>(Math.Max(length * 2, _pool.Capacity * 2));
     }
     return(_pool.GetSpan(length));
 }
示例#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
        public ChainController(IChainStore store, BoundedInbox inbox, BoundedInbox outbox,
                               Action <ILineage> propagateLineage, ILog log = null)
        {
            _store            = store;
            _inbox            = inbox;
            _outbox           = outbox;
            _propagateLineage = propagateLineage;
            _log = log;

            _pool = new SpanPool <byte>(GetBlockInfoResponse.SizeInBytes);
            _mre  = new ManualResetEvent(false);

            RefreshAndPropagateLineage();
        }
示例#5
0
 public ConnectionController(BoundedInbox dispatchInbox, ISocketLike socket, ClientId clientId, ILog log = null)
 {
     _dispatchInbox       = dispatchInbox ?? throw new ArgumentNullException(nameof(dispatchInbox));
     _outbox              = new BoundedInbox(Constants.ConnectionControllerOutboxSize);
     _socket              = socket ?? throw new ArgumentNullException(nameof(socket));
     _clientId            = clientId;
     _log                 = log;
     _bufferIn            = new byte[Constants.MaxRequestSize];
     _mre                 = new ManualResetEvent(false);
     _tokenSource         = new CancellationTokenSource();
     _requestsInProgress  = 0;
     _responsePool        = new SpanPool <byte>(ResponsePoolSize);
     _responseCountInPool = 0;
 }