mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-22 02:34:29 +00:00
misc changes
This commit is contained in:
parent
d0055f16bd
commit
a14f122568
2 changed files with 14 additions and 8 deletions
|
@ -25,7 +25,9 @@ use cuprate_helper::{
|
||||||
cast::usize_to_u64,
|
cast::usize_to_u64,
|
||||||
map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits},
|
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::InternalPeerID;
|
||||||
use cuprate_p2p_core::{
|
use cuprate_p2p_core::{
|
||||||
client::PeerInformation, NetZoneAddress, NetworkZone, ProtocolRequest, ProtocolResponse,
|
client::PeerInformation, NetZoneAddress, NetworkZone, ProtocolRequest, ProtocolResponse,
|
||||||
|
@ -206,7 +208,7 @@ async fn get_chain(
|
||||||
request: ChainRequest,
|
request: ChainRequest,
|
||||||
mut blockchain_read_handle: BlockchainReadHandle,
|
mut blockchain_read_handle: BlockchainReadHandle,
|
||||||
) -> anyhow::Result<ProtocolResponse> {
|
) -> 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.")
|
anyhow::bail!("Peer sent too many block hashes in chain request.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,6 +389,7 @@ where
|
||||||
|
|
||||||
let context = context.unchecked_blockchain_context();
|
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)
|
if usize_to_u64(context.chain_height + 2)
|
||||||
< peer_information
|
< peer_information
|
||||||
.core_sync_data
|
.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
|
let res = incoming_tx_handler
|
||||||
.ready()
|
.ready()
|
||||||
.await
|
.await
|
||||||
.expect(PANIC_CRITICAL_SERVICE_ERROR)
|
.expect(PANIC_CRITICAL_SERVICE_ERROR)
|
||||||
.call(IncomingTxs {
|
.call(IncomingTxs { txs, state })
|
||||||
txs: request.txs,
|
|
||||||
state,
|
|
||||||
})
|
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match res {
|
match res {
|
||||||
|
|
|
@ -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>
|
/// 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.
|
// 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.
|
/// The amount of failures downloading a specific batch before we stop attempting to download it.
|
||||||
pub(crate) const MAX_DOWNLOAD_FAILURES: usize = 5;
|
pub(crate) const MAX_DOWNLOAD_FAILURES: usize = 5;
|
||||||
|
|
Loading…
Reference in a new issue