misc changes

This commit is contained in:
Boog900 2024-11-01 15:13:34 +00:00
parent d0055f16bd
commit a14f122568
No known key found for this signature in database
GPG key ID: 42AB1287CB0041C2
2 changed files with 14 additions and 8 deletions

View file

@ -25,7 +25,9 @@ use cuprate_helper::{
cast::usize_to_u64,
map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits},
};
use cuprate_p2p::constants::{MAX_BLOCK_BATCH_LEN, MAX_TRANSACTION_BLOB_SIZE, MEDIUM_BAN};
use cuprate_p2p::constants::{
MAX_BLOCKS_IDS_IN_CHAIN_ENTRY, MAX_BLOCK_BATCH_LEN, MAX_TRANSACTION_BLOB_SIZE, MEDIUM_BAN,
};
use cuprate_p2p_core::client::InternalPeerID;
use cuprate_p2p_core::{
client::PeerInformation, NetZoneAddress, NetworkZone, ProtocolRequest, ProtocolResponse,
@ -206,7 +208,7 @@ async fn get_chain(
request: ChainRequest,
mut blockchain_read_handle: BlockchainReadHandle,
) -> anyhow::Result<ProtocolResponse> {
if request.block_ids.len() > 25_000 {
if request.block_ids.len() > MAX_BLOCKS_IDS_IN_CHAIN_ENTRY {
anyhow::bail!("Peer sent too many block hashes in chain request.")
}
@ -387,6 +389,7 @@ where
let context = context.unchecked_blockchain_context();
// If we are more than 2 blocks behind the peer then ignore the txs - we are probably still syncing.
if usize_to_u64(context.chain_height + 2)
< peer_information
.core_sync_data
@ -405,15 +408,18 @@ where
}
};
drop(request.padding);
// Drop all the data except the stuff we still need.
let NewTransactions {
txs,
dandelionpp_fluff: _,
padding: _,
} = request;
let res = incoming_tx_handler
.ready()
.await
.expect(PANIC_CRITICAL_SERVICE_ERROR)
.call(IncomingTxs {
txs: request.txs,
state,
})
.call(IncomingTxs { txs, state })
.await;
match res {

View file

@ -67,7 +67,7 @@ pub const MAX_TRANSACTION_BLOB_SIZE: usize = 1_000_000;
///
/// ref: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/cryptonote_config.h#L97>
// TODO: link to the protocol book when this section is added.
pub(crate) const MAX_BLOCKS_IDS_IN_CHAIN_ENTRY: usize = 25_000;
pub const MAX_BLOCKS_IDS_IN_CHAIN_ENTRY: usize = 25_000;
/// The amount of failures downloading a specific batch before we stop attempting to download it.
pub(crate) const MAX_DOWNLOAD_FAILURES: usize = 5;