mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: use get_pooled_transaction_elements in network manager (#4329)
This commit is contained in:
@ -24,8 +24,8 @@ use reth_primitives::{
|
||||
};
|
||||
use reth_rlp::Encodable;
|
||||
use reth_transaction_pool::{
|
||||
error::PoolResult, PoolTransaction, PropagateKind, PropagatedTransactions, TransactionPool,
|
||||
ValidPoolTransaction,
|
||||
error::PoolResult, GetPooledTransactionLimit, PoolTransaction, PropagateKind,
|
||||
PropagatedTransactions, TransactionPool, ValidPoolTransaction,
|
||||
};
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap},
|
||||
@ -52,6 +52,10 @@ const MAX_FULL_TRANSACTIONS_PACKET_SIZE: usize = 100 * 1024;
|
||||
/// <https://github.com/ethereum/devp2p/blob/master/caps/eth.md#newpooledtransactionhashes-0x08>
|
||||
const GET_POOLED_TRANSACTION_SOFT_LIMIT_NUM_HASHES: usize = 256;
|
||||
|
||||
/// Softlimit for the response size of a GetPooledTransactions message (2MB)
|
||||
const GET_POOLED_TRANSACTION_SOFT_LIMIT_SIZE: GetPooledTransactionLimit =
|
||||
GetPooledTransactionLimit::SizeSoftLimit(2 * 1024 * 1024);
|
||||
|
||||
/// The future for inserting a function into the pool
|
||||
pub type PoolImportFuture = Pin<Box<dyn Future<Output = PoolResult<TxHash>> + Send + 'static>>;
|
||||
|
||||
@ -182,19 +186,15 @@ where
|
||||
response: oneshot::Sender<RequestResult<PooledTransactions>>,
|
||||
) {
|
||||
if let Some(peer) = self.peers.get_mut(&peer_id) {
|
||||
// TODO softResponseLimit 2 * 1024 * 1024
|
||||
let transactions = self
|
||||
.pool
|
||||
.get_all(request.0)
|
||||
.into_iter()
|
||||
.map(|tx| tx.transaction.to_recovered_transaction().into_signed())
|
||||
.collect::<Vec<_>>();
|
||||
.get_pooled_transaction_elements(request.0, GET_POOLED_TRANSACTION_SOFT_LIMIT_SIZE);
|
||||
|
||||
// we sent a response at which point we assume that the peer is aware of the transaction
|
||||
peer.transactions.extend(transactions.iter().map(|tx| tx.hash()));
|
||||
// we sent a response at which point we assume that the peer is aware of the
|
||||
// transactions
|
||||
peer.transactions.extend(transactions.iter().map(|tx| *tx.hash()));
|
||||
|
||||
// TODO: remove this! this will be different when we introduce the blobpool
|
||||
let resp = PooledTransactions(transactions.into_iter().map(Into::into).collect());
|
||||
let resp = PooledTransactions(transactions);
|
||||
let _ = response.send(Ok(resp));
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,10 +165,7 @@ use std::{
|
||||
use tokio::sync::mpsc::Receiver;
|
||||
use tracing::{instrument, trace};
|
||||
|
||||
use crate::{
|
||||
blobstore::{BlobStore, BlobStoreError},
|
||||
traits::GetPooledTransactionLimit,
|
||||
};
|
||||
use crate::blobstore::{BlobStore, BlobStoreError};
|
||||
pub use crate::{
|
||||
config::{
|
||||
PoolConfig, PriceBumpConfig, SubPoolLimit, DEFAULT_PRICE_BUMP, REPLACE_BLOB_PRICE_BUMP,
|
||||
@ -183,9 +180,9 @@ pub use crate::{
|
||||
},
|
||||
traits::{
|
||||
AllPoolTransactions, BestTransactions, BlockInfo, CanonicalStateUpdate, ChangedAccount,
|
||||
EthPooledTransaction, NewTransactionEvent, PendingTransactionListenerKind, PoolSize,
|
||||
PoolTransaction, PropagateKind, PropagatedTransactions, TransactionOrigin, TransactionPool,
|
||||
TransactionPoolExt,
|
||||
EthPooledTransaction, GetPooledTransactionLimit, NewTransactionEvent,
|
||||
PendingTransactionListenerKind, PoolSize, PoolTransaction, PropagateKind,
|
||||
PropagatedTransactions, TransactionOrigin, TransactionPool, TransactionPoolExt,
|
||||
},
|
||||
validate::{
|
||||
EthTransactionValidator, TransactionValidationOutcome, TransactionValidationTaskExecutor,
|
||||
|
||||
Reference in New Issue
Block a user