mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add validate transactions function (#5010)
This commit is contained in:
@ -56,9 +56,9 @@ where
|
|||||||
/// See also [Self::validate_one]
|
/// See also [Self::validate_one]
|
||||||
pub fn validate_all(
|
pub fn validate_all(
|
||||||
&self,
|
&self,
|
||||||
transaction: Vec<(TransactionOrigin, Tx)>,
|
transactions: Vec<(TransactionOrigin, Tx)>,
|
||||||
) -> Vec<TransactionValidationOutcome<Tx>> {
|
) -> Vec<TransactionValidationOutcome<Tx>> {
|
||||||
transaction.into_iter().map(|(origin, tx)| self.validate_one(origin, tx)).collect()
|
transactions.into_iter().map(|(origin, tx)| self.validate_one(origin, tx)).collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +78,13 @@ where
|
|||||||
self.validate_one(origin, transaction)
|
self.validate_one(origin, transaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn validate_transactions(
|
||||||
|
&self,
|
||||||
|
transactions: Vec<(TransactionOrigin, Self::Transaction)>,
|
||||||
|
) -> Vec<TransactionValidationOutcome<Self::Transaction>> {
|
||||||
|
self.validate_all(transactions)
|
||||||
|
}
|
||||||
|
|
||||||
fn on_new_head_block(&self, new_tip_block: &SealedBlock) {
|
fn on_new_head_block(&self, new_tip_block: &SealedBlock) {
|
||||||
self.inner.on_new_head_block(new_tip_block)
|
self.inner.on_new_head_block(new_tip_block)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -168,6 +168,21 @@ pub trait TransactionValidator: Send + Sync {
|
|||||||
transaction: Self::Transaction,
|
transaction: Self::Transaction,
|
||||||
) -> TransactionValidationOutcome<Self::Transaction>;
|
) -> TransactionValidationOutcome<Self::Transaction>;
|
||||||
|
|
||||||
|
/// Validates a batch of transactions.
|
||||||
|
///
|
||||||
|
/// Must return all outcomes for the given transactions in the same order.
|
||||||
|
///
|
||||||
|
/// See also [Self::validate_transaction].
|
||||||
|
async fn validate_transactions(
|
||||||
|
&self,
|
||||||
|
transactions: Vec<(TransactionOrigin, Self::Transaction)>,
|
||||||
|
) -> Vec<TransactionValidationOutcome<Self::Transaction>> {
|
||||||
|
futures_util::future::join_all(
|
||||||
|
transactions.into_iter().map(|(origin, tx)| self.validate_transaction(origin, tx)),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
/// Invoked when the head block changes.
|
/// Invoked when the head block changes.
|
||||||
///
|
///
|
||||||
/// This can be used to update fork specific values (timestamp).
|
/// This can be used to update fork specific values (timestamp).
|
||||||
|
|||||||
Reference in New Issue
Block a user