Skip to content

Commit 1202a62

Browse files
authored
fix(rust/cardano-chain-follower): Check condition for Block Roll Forward (#56)
* fix(rust/cardano-chain-follower): fix follow chain example argument name * fix(rust/cardano-chain-follower): explicit condition for block roll forward
1 parent 817889a commit 1202a62

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

rust/cardano-chain-follower/examples/follow_chains.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async fn start_sync_for(network: &Network, matches: ArgMatches) -> Result<(), Bo
111111
mithril_dl_connect_timeout = format!("{}", humantime::format_duration(connect_timeout));
112112
}
113113

114-
if let Some(data_timeout) = matches.get_one::<u64>("mithril-sync-data-timeout") {
114+
if let Some(data_timeout) = matches.get_one::<u64>("mithril-sync-data-read-timeout") {
115115
dl_config = dl_config.with_connection_timeout(Duration::from_secs(*data_timeout));
116116
}
117117
if let Some(data_timeout) = dl_config.data_read_timeout {

rust/cardano-chain-follower/src/follow.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,13 @@ impl ChainFollower {
109109
}
110110
}
111111

112-
if (self.mithril_tip.is_none() || current_mithril_tip > self.mithril_tip)
113-
&& self.current < self.mithril_tip
114-
{
112+
let roll_forward_condition = if let Some(mithril_tip) = &self.mithril_tip {
113+
current_mithril_tip > *mithril_tip && *mithril_tip > self.current
114+
} else {
115+
true
116+
};
117+
118+
if roll_forward_condition {
115119
let snapshot = MithrilSnapshot::new(self.chain);
116120
if let Some(block) = snapshot.read_block_at(&current_mithril_tip).await {
117121
// The Mithril Tip has moved forwards.

0 commit comments

Comments
 (0)