public IEnumerable <Transaction> GetTransactions(BlockHeader parent, long gasLimit) { foreach (Transaction tx in _innerSource.GetTransactions(parent, gasLimit)) { if (tx is T) { AcceptTxResult acceptTxResult = _txFilter.IsAllowed(tx, parent); if (acceptTxResult) { if (_logger.IsTrace) { _logger.Trace($"Selected {tx.ToShortString()} to be included in block."); } yield return(tx); } else { if (_logger.IsDebug) { _logger.Debug($"Rejecting ({acceptTxResult}) {tx.ToShortString()}"); } } } else { if (_logger.IsTrace) { _logger.Trace($"Selected {tx.ToShortString()} to be included in block, skipped validation for {tx.GetType()}."); } yield return(tx); } } }
public AcceptTxResult IsAllowed(Transaction tx, BlockHeader parentHeader) { for (int i = 0; i < _txFilters.Length; i++) { AcceptTxResult isAllowed = _txFilters[i].IsAllowed(tx, parentHeader); if (!isAllowed) { return(isAllowed); } } return(AcceptTxResult.Accepted); }
public AcceptTxResult IsAllowed(Transaction tx, BlockHeader parentHeader) { AcceptTxResult isAllowed = _minGasPriceFilter.IsAllowed(tx, parentHeader); if (!isAllowed) { return(isAllowed); } else if (_minGasPrices.TryGetValue(parentHeader, tx, out TxPriorityContract.Destination @override)) { return(_minGasPriceFilter.IsAllowed(tx, parentHeader, @override.Value)); } return(AcceptTxResult.Accepted); }
protected void Handle(TransactionsMessage msg) { IList <Transaction> transactions = msg.Transactions; for (int i = 0; i < transactions.Count; i++) { Transaction tx = transactions[i]; tx.DeliveredBy = Node.Id; tx.Timestamp = _timestamper.UnixTime.Seconds; AcceptTxResult accepted = _txPool.SubmitTx(tx, TxHandlingOptions.None); _floodController.Report(accepted); if (Logger.IsTrace) { Logger.Trace( $"{Node:c} sent {tx.Hash} tx and it was {accepted} (chain ID = {tx.Signature?.ChainId})"); } } }
public bool Execute(Transaction tx, BlockHeader parentHeader) { if (_filters.Count == 0) { return(true); } foreach (ITxFilter filter in _filters) { AcceptTxResult isAllowed = filter.IsAllowed(tx, parentHeader); if (!isAllowed) { if (_logger.IsDebug) { _logger.Debug($"Rejected tx ({isAllowed}) {tx.ToShortString()}"); } return(false); } } return(true); }
public AcceptTxResult Accept(Transaction tx, TxHandlingOptions txHandlingOptions) { if (tx is not GeneratedTransaction) { BlockHeader parentHeader = _blockTree.Head?.Header; if (parentHeader == null) { return(AcceptTxResult.Accepted); } AcceptTxResult isAllowed = _txFilter.IsAllowed(tx, parentHeader); if (!isAllowed) { if (_logger.IsTrace) { _logger.Trace($"Skipped adding transaction {tx.ToString(" ")}, filtered ({isAllowed})."); } } return(isAllowed); } return(AcceptTxResult.Accepted); }