mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: use flz estimate (#13930)
This commit is contained in:
@ -61,22 +61,12 @@ impl OpPooledTransaction {
|
||||
/// This value is computed based on the following formula:
|
||||
/// `max(minTransactionSize, intercept + fastlzCoef*fastlzSize)`
|
||||
pub fn estimated_compressed_size(&self) -> u64 {
|
||||
*self
|
||||
.estimated_tx_compressed_size
|
||||
.get_or_init(|| tx_estimated_size_fjord(&self.inner.transaction().encoded_2718()))
|
||||
*self.estimated_tx_compressed_size.get_or_init(|| {
|
||||
op_alloy_flz::tx_estimated_size_fjord(&self.inner.transaction().encoded_2718())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculate the estimated compressed transaction size in bytes, scaled by 1e6.
|
||||
/// This value is computed based on the following formula:
|
||||
/// max(minTransactionSize, intercept + fastlzCoef*fastlzSize)
|
||||
// TODO(mattsse): replace with library fn from revm or maili once available
|
||||
fn tx_estimated_size_fjord(input: &[u8]) -> u64 {
|
||||
let fastlz_size = op_alloy_flz::flz_compress_len(input) as u64;
|
||||
|
||||
fastlz_size.saturating_mul(836_500).saturating_sub(42_585_600).max(100_000_000)
|
||||
}
|
||||
|
||||
impl From<Recovered<op_alloy_consensus::OpPooledTransaction>> for OpPooledTransaction {
|
||||
fn from(tx: Recovered<op_alloy_consensus::OpPooledTransaction>) -> Self {
|
||||
let encoded_len = tx.encode_2718_len();
|
||||
|
||||
Reference in New Issue
Block a user