def broadcast_transactions_to_node( self, msg: AbstractMessage, broadcasting_conn: Optional[AbstractConnection]) -> bool: msg = cast(TransactionsEthProtocolMessage, msg) if self.opts.filter_txs_factor > 0: assert len(msg.get_transactions()) == 1 transaction = msg.get_transactions()[0] if (float(transaction.gas_price) < self.average_gas_price.average * self.opts.filter_txs_factor): logger.trace( "Skipping sending transaction {} with gas price: {}. Average was {}", transaction.hash(), float(transaction.gas_price), self.average_gas_price.average) return False return super().broadcast_transactions_to_node(msg, broadcasting_conn)
def broadcast_transactions_to_nodes( self, msg: AbstractMessage, broadcasting_conn: Optional[AbstractConnection]) -> bool: msg = cast(TransactionsEthProtocolMessage, msg) if self.opts.filter_txs_factor > 0: average_block_gas_filter = self.average_block_gas_price.average * self.opts.filter_txs_factor else: average_block_gas_filter = 0 min_gas_price_from_node = self.min_tx_from_node_gas_price.current_minimum gas_price_filter = max(average_block_gas_filter, min_gas_price_from_node) if gas_price_filter > 0: assert len(msg.get_transactions()) == 1 transaction = msg.get_transactions()[0] gas_price = float(transaction.gas_price) if gas_price < gas_price_filter: logger.trace( "Skipping sending transaction {} with gas price: {}. Average was {}. Minimum from node was {}.", transaction.hash(), float(transaction.gas_price), average_block_gas_filter, min_gas_price_from_node) tx_stats.add_tx_by_hash_event( transaction.hash(), TransactionStatEventType.TX_FROM_BDN_IGNORE_LOW_GAS_PRICE, self.network_num, peers=[broadcasting_conn], more_info= "Tx gas price {}. Average block gas price: {}. Node min gas price {}." .format(gas_price, average_block_gas_filter, min_gas_price_from_node)) return False return super().broadcast_transactions_to_nodes(msg, broadcasting_conn)