feat: restructure op builder (#12229)

This commit is contained in:
Matthias Seitz
2024-11-05 15:04:52 +01:00
committed by GitHub
parent 15c230bac2
commit 5af551782c
3 changed files with 623 additions and 321 deletions

File diff suppressed because it is too large Load Diff

View File

@ -790,6 +790,37 @@ impl<Payload> BuildOutcome<Payload> {
}
}
/// The possible outcomes of a payload building attempt without reused [`CachedReads`]
#[derive(Debug)]
pub enum BuildOutcomeKind<Payload> {
/// Successfully built a better block.
Better {
/// The new payload that was built.
payload: Payload,
},
/// Aborted payload building because resulted in worse block wrt. fees.
Aborted {
/// The total fees associated with the attempted payload.
fees: U256,
},
/// Build job was cancelled
Cancelled,
/// The payload is final and no further building should occur
Freeze(Payload),
}
impl<Payload> BuildOutcomeKind<Payload> {
/// Attaches the [`CachedReads`] to the outcome.
pub fn with_cached_reads(self, cached_reads: CachedReads) -> BuildOutcome<Payload> {
match self {
Self::Better { payload } => BuildOutcome::Better { payload, cached_reads },
Self::Aborted { fees } => BuildOutcome::Aborted { fees, cached_reads },
Self::Cancelled => BuildOutcome::Cancelled,
Self::Freeze(payload) => BuildOutcome::Freeze(payload),
}
}
}
/// A collection of arguments used for building payloads.
///
/// This struct encapsulates the essential components and configuration required for the payload

View File

@ -739,6 +739,11 @@ impl fmt::Display for CanonicalStateUpdate<'_> {
}
}
/// Alias to restrict the [`BestTransactions`] items to the pool's transaction type.
pub type BestTransactionsFor<Pool> = Box<
dyn BestTransactions<Item = Arc<ValidPoolTransaction<<Pool as TransactionPool>::Transaction>>>,
>;
/// An `Iterator` that only returns transactions that are ready to be executed.
///
/// This makes no assumptions about the order of the transactions, but expects that _all_