Skip to content

Commit d63192f

Browse files
committed
fix(cardano-chain-follower): magic number
Signed-off-by: bkioshn <[email protected]>
1 parent 19b06b8 commit d63192f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl ChainFollower {
7575
end,
7676
previous: Point::UNKNOWN,
7777
current: start,
78-
fork: 1.into(), // This is correct, because Mithril is Fork 0.
78+
fork: Fork::BACKFILL, // This is correct, because Mithril is Fork 0.
7979
snapshot: MithrilSnapshot::new(chain),
8080
mithril_follower: None,
8181
mithril_tip: None,

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
sync::{Arc, Mutex},
77
};
88

9-
use cardano_blockchain_types::{MultiEraBlock, Network, Point};
9+
use cardano_blockchain_types::{Fork, MultiEraBlock, Network, Point};
1010
use logcall::logcall;
1111
use tokio::task;
1212
use tracing::{debug, error};
@@ -52,12 +52,14 @@ pub(crate) struct MithrilSnapshotIterator {
5252

5353
/// Create a probe point used in iterations to find the start when its not exactly known.
5454
pub(crate) fn probe_point(point: &Point, distance: u64) -> Point {
55+
/// Step back point to indicate origin.
56+
const STEP_BACK_ORIGIN: u64 = 0;
5557
// Now that we have the tip, step back about 4 block intervals from tip, and do a fuzzy
5658
// iteration to find the exact two blocks at the end of the immutable chain.
5759
let step_back_search = point.slot_or_default() - distance.into();
5860

5961
// We stepped back to the origin, so just return Origin
60-
if step_back_search == 0.into() {
62+
if step_back_search == STEP_BACK_ORIGIN.into() {
6163
return Point::ORIGIN;
6264
}
6365

@@ -210,7 +212,7 @@ impl Iterator for MithrilSnapshotIteratorInner {
210212
if let Ok(block) = maybe_block {
211213
if !self.previous.is_unknown() {
212214
// We can safely fully decode this block.
213-
match MultiEraBlock::new(self.chain, block, &self.previous, 0.into()) {
215+
match MultiEraBlock::new(self.chain, block, &self.previous, Fork::IMMUTABLE) {
214216
Ok(block_data) => {
215217
// Update the previous point
216218
// debug!("Pre Previous update 1 : {:?}", self.previous);

0 commit comments

Comments
 (0)