Skip to content
Snippets Groups Projects
Commit 5e4af21f authored by Éloïs's avatar Éloïs
Browse files

[fix] bc: do not request fork blocks where current block is genesis

parent 8d8defa7
No related branches found
No related tags found
2 merge requests!232Elois/local validation,!221WIP: Resolve "Fail to revert block with transactions"
......@@ -49,6 +49,7 @@ pub fn request_fork_blocks(bc: &mut BlockchainModule, now: SystemTime) {
bc.last_request_fork_blocks = now;
// Request all blocks in fork window size
if let Some(currency_params) = bc.currency_params {
if bc.current_blockstamp.id > BlockNumber(0) {
let fork_window_size = currency_params.fork_window_size as u32;
let from = if bc.current_blockstamp.id.0 > fork_window_size {
BlockNumber(bc.current_blockstamp.id.0 - fork_window_size)
......@@ -56,13 +57,15 @@ pub fn request_fork_blocks(bc: &mut BlockchainModule, now: SystemTime) {
BlockNumber(0)
};
let to = bc.current_blockstamp.id;
let new_pending_network_requests = dunp::queries::request_blocks_from_to(bc, from, to);
let new_pending_network_requests =
dunp::queries::request_blocks_from_to(bc, from, to);
for (new_req_id, new_req) in new_pending_network_requests {
bc.pending_network_requests.insert(new_req_id, new_req);
}
}
}
}
}
pub fn request_next_main_blocks(bc: &mut BlockchainModule, now: SystemTime) {
// Choose frequency
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment