Skip to content

Commit

Permalink
grin v5.3 (0118) 'Turn on' PIBD on main-net, in advance of 5.2.0 rele…
Browse files Browse the repository at this point in the history
…ase (mimblewimble#3750)

* remove non-mainnet check for PIBD requests
* remove surplus flag
* use matches! macro
* fix match logic
* correct match logic
  • Loading branch information
bayk committed Jun 21, 2024
1 parent e176ae9 commit 29ff6a1
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions servers/src/grin/sync/state_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub struct StateSync {
last_logged_time: i64,
last_download_size: u64,

pibd_aborted: bool,
earliest_zero_pibd_peer_time: Option<DateTime<Utc>>,
}

Expand All @@ -58,16 +57,10 @@ impl StateSync {
state_sync_peer: None,
last_logged_time: 0,
last_download_size: 0,
pibd_aborted: false,
earliest_zero_pibd_peer_time: None,
}
}

/// Flag to abort PIBD process
pub fn set_pibd_aborted(&mut self) {
self.pibd_aborted = true;
}

/// Record earliest time at which we had no suitable
/// peers for continuing PIBD
pub fn set_earliest_zero_pibd_peer_time(&mut self, t: Option<DateTime<Utc>>) {
Expand Down Expand Up @@ -99,20 +92,10 @@ impl StateSync {

// Determine whether we're going to try using PIBD or whether we've already given up
// on it
let using_pibd =
if let SyncStatus::TxHashsetPibd { aborted: true, .. } = self.sync_state.status() {
false
} else if self.pibd_aborted {
false
} else {
// Only on testing chains for now
if global::get_chain_type() != global::ChainTypes::Mainnet {
true
//false
} else {
false
}
};
let using_pibd = !matches!(
self.sync_state.status(),
SyncStatus::TxHashsetPibd { aborted: true, .. },
);

// Check whether we've errored and should restart pibd
if using_pibd {
Expand Down Expand Up @@ -337,7 +320,6 @@ impl StateSync {
.update_pibd_progress(true, true, 0, 1, &archive_header);
self.sync_state
.set_sync_error(chain::Error::AbortingPIBDError);
self.set_pibd_aborted();
return false;
}
} else {
Expand Down

0 comments on commit 29ff6a1

Please sign in to comment.