fixed debugging

This commit is contained in:
viraladmin 2026-05-26 17:33:03 -06:00
parent c74784ef32
commit c2f907a36a
6 changed files with 30 additions and 6 deletions

View File

@ -38,9 +38,17 @@ pub async fn create_genesis_block(
return; return;
} }
}; };
handle_response_and_save_torrent(0, &db, torrent, wallet_key, map.clone(), false) handle_response_and_save_torrent(
.await 0,
.ok(); &db,
torrent,
wallet_key,
map.clone(),
false,
false,
)
.await
.ok();
} }
} }
} }

View File

@ -73,6 +73,7 @@ pub async fn save_new_blocks(
wallet_key, wallet_key,
params.map.clone(), params.map.clone(),
true, true,
true,
) )
.await .await
{ {
@ -191,6 +192,7 @@ pub async fn save_new_blocks(
wallet_key, wallet_key,
params.map.clone(), params.map.clone(),
true, true,
true,
) )
.await?; .await?;
if get_height(&params.db) <= local_height_before { if get_height(&params.db) <= local_height_before {

View File

@ -117,6 +117,7 @@ async fn replay_staged_torrents(params: &OrphanCheckup2, wallet_key: &str) -> Re
wallet_key, wallet_key,
params.map.clone(), params.map.clone(),
true, true,
true,
) )
.await .await
{ {

View File

@ -79,6 +79,7 @@ pub async fn node_syncing(
wallet_key, wallet_key,
map.clone(), map.clone(),
false, false,
false,
) )
.await .await
{ {

View File

@ -132,6 +132,15 @@ pub async fn torrent_submission(
let reorganizing = is_reorganizing_mode(); let reorganizing = is_reorganizing_mode();
let process_now = !syncing && !reorganizing && height == expected_height; let process_now = !syncing && !reorganizing && height == expected_height;
if height < expected_height && !(height > 0 && within_orphan_window(local_height, height)) {
// Far-stale torrents cannot affect the orphan window. Ignore them
// before parsing or staging so syncing peers do not flood old
// metadata into local replay storage.
return TorrentSubmissionOutcome::Accepted(RpcResponse::Binary(
"Torrent ignored as stale.".as_bytes().to_vec(),
));
}
// The sender receives an acknowledgement for staging even when the // The sender receives an acknowledgement for staging even when the
// torrent cannot be processed immediately. // torrent cannot be processed immediately.
let staged_response = if syncing { let staged_response = if syncing {

View File

@ -40,6 +40,7 @@ pub async fn handle_response_and_save_torrent(
wallet_key: &str, wallet_key: &str,
map: Arc<Mutex<Command>>, map: Arc<Mutex<Command>>,
allow_during_reorg: bool, allow_during_reorg: bool,
rebroadcast: bool,
) -> Result<(), String> { ) -> Result<(), String> {
let Some((torrent, staged_path)) = let Some((torrent, staged_path)) =
stage_and_verify_torrent(height, db, torrent, wallet_key, true).await? stage_and_verify_torrent(height, db, torrent, wallet_key, true).await?
@ -58,9 +59,11 @@ pub async fn handle_response_and_save_torrent(
) )
.await?; .await?;
// A requested torrent is only forwarded after this node has the if rebroadcast {
// complete validated block available for piece requests. // A requested torrent is only forwarded after this node has the
broadcast_new_torrent_to_peers(height, &torrent_bytes, map).await; // complete validated block available for piece requests.
broadcast_new_torrent_to_peers(height, &torrent_bytes, map).await;
}
Ok(()) Ok(())
} }