Add propagate field to TransactionValidationOutcome (#3664)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
lukebrich.eth
2023-07-07 18:32:40 -04:00
committed by GitHub
parent a7f32dbb0b
commit 42a824cf95
4 changed files with 11 additions and 2 deletions

View File

@@ -170,6 +170,7 @@ impl<T: PoolTransaction> TransactionValidator for NoopTransactionValidator<T> {
balance: Default::default(),
state_nonce: 0,
transaction,
propagate: true,
}
}
}

View File

@@ -274,7 +274,12 @@ where
tx: TransactionValidationOutcome<T::Transaction>,
) -> PoolResult<TxHash> {
match tx {
TransactionValidationOutcome::Valid { balance, state_nonce, transaction } => {
TransactionValidationOutcome::Valid {
balance,
state_nonce,
transaction,
propagate,
} => {
let sender_id = self.get_sender_id(transaction.sender());
let transaction_id = TransactionId::new(sender_id, transaction.nonce());
let encoded_length = transaction.encoded_length();
@@ -282,7 +287,7 @@ where
let tx = ValidPoolTransaction {
transaction,
transaction_id,
propagate: false,
propagate,
timestamp: Instant::now(),
origin,
encoded_length,

View File

@@ -311,6 +311,7 @@ where
balance: account.balance,
state_nonce: account.nonce,
transaction,
propagate: true,
}
}
}

View File

@@ -30,6 +30,8 @@ pub enum TransactionValidationOutcome<T: PoolTransaction> {
state_nonce: u64,
/// Validated transaction.
transaction: T,
/// Whether to propagate the transaction to the network.
propagate: bool,
},
/// The transaction is considered invalid indefinitely: It violates constraints that prevent
/// this transaction from ever becoming valid.