mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
fix: correctly fetch pending hashes (#19938)
This commit is contained in:
@@ -423,7 +423,7 @@ impl<N: NetworkPrimitives> TransactionFetcher<N> {
|
||||
&mut self,
|
||||
peers: &HashMap<PeerId, PeerMetadata<N>>,
|
||||
has_capacity_wrt_pending_pool_imports: impl Fn(usize) -> bool,
|
||||
) {
|
||||
) -> bool {
|
||||
let mut hashes_to_request = RequestTxHashes::with_capacity(
|
||||
DEFAULT_MARGINAL_COUNT_HASHES_GET_POOLED_TRANSACTIONS_REQUEST,
|
||||
);
|
||||
@@ -440,7 +440,7 @@ impl<N: NetworkPrimitives> TransactionFetcher<N> {
|
||||
budget_find_idle_fallback_peer,
|
||||
) else {
|
||||
// no peers are idle or budget is depleted
|
||||
return
|
||||
return false
|
||||
};
|
||||
|
||||
peer_id
|
||||
@@ -449,7 +449,7 @@ impl<N: NetworkPrimitives> TransactionFetcher<N> {
|
||||
);
|
||||
|
||||
// peer should always exist since `is_session_active` already checked
|
||||
let Some(peer) = peers.get(&peer_id) else { return };
|
||||
let Some(peer) = peers.get(&peer_id) else { return false };
|
||||
let conn_eth_version = peer.version;
|
||||
|
||||
// fill the request with more hashes pending fetch that have been announced by the peer.
|
||||
@@ -493,7 +493,10 @@ impl<N: NetworkPrimitives> TransactionFetcher<N> {
|
||||
);
|
||||
|
||||
self.buffer_hashes(failed_to_request_hashes, Some(peer_id));
|
||||
return false
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
/// Filters out hashes that have been seen before. For hashes that have already been seen, the
|
||||
|
||||
@@ -495,7 +495,9 @@ impl<Pool: TransactionPool, N: NetworkPrimitives> TransactionsManager<Pool, N> {
|
||||
}
|
||||
|
||||
/// Runs an operation to fetch hashes that are cached in [`TransactionFetcher`].
|
||||
fn on_fetch_hashes_pending_fetch(&mut self) {
|
||||
///
|
||||
/// Returns `true` if a request was sent.
|
||||
fn on_fetch_hashes_pending_fetch(&mut self) -> bool {
|
||||
// try drain transaction hashes pending fetch
|
||||
let info = &self.pending_pool_imports_info;
|
||||
let max_pending_pool_imports = info.max_pending_pool_imports;
|
||||
@@ -503,7 +505,7 @@ impl<Pool: TransactionPool, N: NetworkPrimitives> TransactionsManager<Pool, N> {
|
||||
|divisor| info.has_capacity(max_pending_pool_imports / divisor);
|
||||
|
||||
self.transaction_fetcher
|
||||
.on_fetch_pending_hashes(&self.peers, has_capacity_wrt_pending_pool_imports);
|
||||
.on_fetch_pending_hashes(&self.peers, has_capacity_wrt_pending_pool_imports)
|
||||
}
|
||||
|
||||
fn on_request_error(&self, peer_id: PeerId, req_err: RequestError) {
|
||||
@@ -1625,8 +1627,9 @@ where
|
||||
// Sends at most one request.
|
||||
duration_metered_exec!(
|
||||
{
|
||||
if this.has_capacity_for_fetching_pending_hashes() {
|
||||
this.on_fetch_hashes_pending_fetch();
|
||||
if this.has_capacity_for_fetching_pending_hashes() &&
|
||||
this.on_fetch_hashes_pending_fetch()
|
||||
{
|
||||
maybe_more_tx_fetch_events = true;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user