public void RemoveTransaction(Keccak hash)
        {
            if (_pendingTransactions.TryRemove(hash, out var transaction))
            {
                RemovedPending?.Invoke(this, new TransactionEventArgs(transaction));
            }

            if (_ownTransactions.Count != 0)
            {
                bool ownIncluded = _ownTransactions.TryRemove(hash, out _);
                if (ownIncluded)
                {
                    if (_logger.IsInfo)
                    {
                        _logger.Trace($"Transaction {hash} created on this node was included in the block");
                    }
                }
            }

            _transactionStorage.Delete(hash);
            if (_logger.IsTrace)
            {
                _logger.Trace($"Deleted a transaction: {hash}");
            }
        }
Example #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 (_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));
                }
            }
        }
        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 (_pendingTransactionThresholdValidator.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 TransactionEventArgs(transaction));
                }
            }
        }
Example #4
0
        public void RemoveTransaction(Keccak hash)
        {
            if (_pendingTransactions.TryRemove(hash, out var transaction))
            {
                RemovedPending?.Invoke(this, new TransactionEventArgs(transaction));
            }

            _transactionStorage.Delete(hash);
            if (_logger.IsTrace)
            {
                _logger.Trace($"Deleted a transaction: {hash}");
            }
        }