Пример #1
0
        private void OnTimerElapsed(object sender, ElapsedEventArgs eventArgs)
        {
            if (_pendingTransactions.Count == 0)
            {
                return;
            }

            var hashes    = new List <Keccak>();
            var timestamp = new UInt256(_timestamp.EpochSeconds);

            foreach (var transaction in _pendingTransactions.Values)
            {
                if (_nonEvictableTransactions.ContainsKey(transaction.Hash))
                {
                    if (_logger.IsDebug)
                    {
                        _logger.Debug($"Pending transaction: {transaction.Hash} will not be evicted.");
                    }
                    continue;
                }

                if (_pendingTxThresholdValidator.IsRemovable(timestamp, transaction.Timestamp))
                {
                    hashes.Add(transaction.Hash);
                }
            }

            for (var i = 0; i < hashes.Count; i++)
            {
                if (_pendingTransactions.TryRemove(hashes[i], out var transaction))
                {
                    RemovedPending?.Invoke(this, new TxEventArgs(transaction));
                }
            }
        }
Пример #2
0
        private void OnTimerElapsed(object sender, ElapsedEventArgs eventArgs)
        {
            if (_pendingTransactions.Count == 0)
            {
                return;
            }

            var hashes    = new List <Keccak>();
            var timestamp = new UInt256(_timestamp.EpochSeconds);

            foreach (var transaction in _pendingTransactions.Values)
            {
                if (_pendingTxThresholdValidator.IsRemovable(timestamp, transaction.Timestamp))
                {
                    hashes.Add(transaction.Hash);
                }
            }

            for (var i = 0; i < hashes.Count; i++)
            {
                if (_pendingTransactions.TryRemove(hashes[i], out var transaction))
                {
                    RemovedPending?.Invoke(this, new TxEventArgs(transaction));
                }
            }
        }