Skip to content

Commit

Permalink
on second thought, bound the depth of the anti-entropy protocol to wh…
Browse files Browse the repository at this point in the history
…atever the inv-sync depth is
  • Loading branch information
jcnelson committed Mar 30, 2021
1 parent 88f48f9 commit 43bca90
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/net/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2676,17 +2676,11 @@ impl PeerNetwork {
neighbor_keys.push(nk.clone());
}

let reward_cycle_start = if let Some(ref inv_state) = self.inv_state {
let lowest_reward_cycle = self
.burnchain
.block_height_to_reward_cycle(
inv_state.block_sortition_start + sortdb.first_block_height,
)
.unwrap_or(0);
(self.pox_id.len() as u64).saturating_sub(lowest_reward_cycle + 1)
} else {
0
};
// only go so far back
let reward_cycle_start =
self.pox_id
.num_inventory_reward_cycles()
.saturating_sub(self.connection_opts.inv_reward_cycles as usize) as u64;

debug!(
"{:?}: Run anti-entropy protocol for {} neighbors, starting at reward cycle {}",
Expand Down Expand Up @@ -3027,18 +3021,17 @@ impl PeerNetwork {

// hint to the downloader to start scanning at the sortition
// height we just synchronized
let start_download_sortition = if let Some(ref inv_state) =
self.inv_state
{
debug!(
let start_download_sortition =
if let Some(ref inv_state) = self.inv_state {
debug!(
"{:?}: Begin downloader synchronization at sortition height {}",
&self.local_peer, inv_state.block_sortition_start
);
inv_state.block_sortition_start
} else {
// really unreachable, but why tempt fate?
0
};
inv_state.block_sortition_start
} else {
// really unreachable, but why tempt fate?
0
};

if let Some(ref mut downloader) = self.block_downloader {
downloader.hint_block_sortition_height_available(
Expand Down

0 comments on commit 43bca90

Please sign in to comment.