Skip to content

Commit 8e04978

Browse files
committed
fix: force an initial burnchain view load for the p2p network if it hasn't completed a full state-machine pass yet
1 parent b259ba3 commit 8e04978

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

stackslib/src/net/p2p.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5224,7 +5224,12 @@ impl PeerNetwork {
52245224
// update burnchain snapshot if we need to (careful -- it's expensive)
52255225
let sn = SortitionDB::get_canonical_burn_chain_tip(&sortdb.conn())?;
52265226
let mut ret: HashMap<NeighborKey, Vec<StacksMessage>> = HashMap::new();
5227-
if sn.block_height != self.chain_view.burn_block_height {
5227+
let mut need_stackerdb_refresh = sn.canonical_stacks_tip_consensus_hash
5228+
!= self.burnchain_tip.canonical_stacks_tip_consensus_hash;
5229+
5230+
if sn.block_height != self.chain_view.burn_block_height
5231+
|| self.num_state_machine_passes == 0
5232+
{
52285233
debug!(
52295234
"{:?}: load chain view for burn block {}",
52305235
&self.local_peer, sn.block_height
@@ -5303,7 +5308,17 @@ impl PeerNetwork {
53035308
.get_last_selected_anchor_block_txid()?
53045309
.unwrap_or(Txid([0x00; 32]));
53055310

5306-
// refresh stackerdb configs
5311+
test_debug!(
5312+
"{:?}: chain view is {:?}",
5313+
&self.get_local_peer(),
5314+
&self.chain_view
5315+
);
5316+
need_stackerdb_refresh = true;
5317+
}
5318+
5319+
if need_stackerdb_refresh {
5320+
// refresh stackerdb configs -- canonical stacks tip has changed
5321+
debug!("{:?}: Refresh all stackerdbs", &self.get_local_peer());
53075322
let mut new_stackerdb_configs = HashMap::new();
53085323
let stacker_db_configs = mem::replace(&mut self.stacker_db_configs, HashMap::new());
53095324
for (stackerdb_contract_id, stackerdb_config) in stacker_db_configs.into_iter() {

0 commit comments

Comments
 (0)