mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Shorten error message on debug assertion (#6988)
This commit is contained in:
@ -377,9 +377,8 @@ impl TransactionFetcher {
|
||||
for hash in hashes.into_iter() {
|
||||
debug_assert!(
|
||||
self.hashes_fetch_inflight_and_pending_fetch.peek(&hash).is_some(),
|
||||
"`%hash` in `@buffered_hashes` that's not in `@unknown_hashes`, `@buffered_hashes` should be a subset of keys in `@unknown_hashes`, broken invariant `@buffered_hashes` and `@unknown_hashes`,
|
||||
`%hash`: {hash},
|
||||
`@self`: {self:?}",
|
||||
"`%hash` in `@buffered_hashes` that's not in `@hashes_fetch_inflight_and_pending_fetch`, `@buffered_hashes` should be a subset of keys in `@hashes_fetch_inflight_and_pending_fetch`, broken invariant `@buffered_hashes` and `@hashes_fetch_inflight_and_pending_fetch`,
|
||||
`%hash`: {hash}"
|
||||
);
|
||||
|
||||
let Some(TxFetchMetadata { retries, fallback_peers, .. }) =
|
||||
@ -676,10 +675,10 @@ impl TransactionFetcher {
|
||||
true
|
||||
}(),
|
||||
"`%new_announced_hashes` should been taken out of buffer before packing in a request, breaks invariant `@buffered_hashes` and `@inflight_requests`,
|
||||
`%new_announced_hashes`: {:?},
|
||||
`@self`: {:?}",
|
||||
new_announced_hashes, self
|
||||
);
|
||||
`@hashes_fetch_inflight_and_pending_fetch` for `%new_announced_hashes`: {:?}",
|
||||
new_announced_hashes.iter().map(|hash|
|
||||
(*hash, self.hashes_fetch_inflight_and_pending_fetch.get(hash).cloned())
|
||||
).collect::<Vec<(TxHash, Option<TxFetchMetadata>)>>());
|
||||
|
||||
let (response, rx) = oneshot::channel();
|
||||
let req: PeerRequest = PeerRequest::GetPooledTransactions {
|
||||
@ -910,12 +909,13 @@ impl TransactionFetcher {
|
||||
let GetPooledTxResponse { peer_id, mut requested_hashes, result } = response;
|
||||
|
||||
debug_assert!(
|
||||
self.active_peers.get(&peer_id).is_some(),
|
||||
"`%peer_id` has been removed from `@active_peers` before inflight request(s) resolved, broken invariant `@active_peers` and `@inflight_requests`,
|
||||
self.active_peers.get(&peer_id).is_some(),
|
||||
"`%peer_id` has been removed from `@active_peers` before inflight request(s) resolved, broken invariant `@active_peers` and `@inflight_requests`,
|
||||
`%peer_id`: {},
|
||||
`@self`: {:?}",
|
||||
peer_id, self
|
||||
);
|
||||
`@hashes_fetch_inflight_and_pending_fetch` for `%requested_hashes`: {:?}",
|
||||
peer_id, requested_hashes.iter().map(|hash|
|
||||
(*hash, self.hashes_fetch_inflight_and_pending_fetch.get(hash).cloned())
|
||||
).collect::<Vec<(TxHash, Option<TxFetchMetadata>)>>());
|
||||
|
||||
self.decrement_inflight_request_count_for(&peer_id);
|
||||
|
||||
@ -1071,7 +1071,7 @@ impl Default for TransactionFetcher {
|
||||
}
|
||||
|
||||
/// Metadata of a transaction hash that is yet to be fetched.
|
||||
#[derive(Debug, Constructor)]
|
||||
#[derive(Debug, Constructor, Clone)]
|
||||
pub struct TxFetchMetadata {
|
||||
/// The number of times a request attempt has been made for the hash.
|
||||
retries: u8,
|
||||
|
||||
Reference in New Issue
Block a user