Skip to content

Commit 4d1aea0

Browse files
committed
fix(cardano-chain-follower): fix type
1 parent e645601 commit 4d1aea0

File tree

9 files changed

+16
-152
lines changed

9 files changed

+16
-152
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ async fn process_rollback(
189189
) -> anyhow::Result<Point> {
190190
let rollback_slot = point.slot_or_default();
191191
let head_slot = previous_point.slot_or_default();
192-
debug!("Head slot: {}", head_slot);
193-
debug!("Rollback slot: {}", rollback_slot);
192+
debug!("Head slot: {head_slot:?}");
193+
debug!("Rollback slot: {rollback_slot:?}");
194194
let slot_rollback_size = if head_slot > rollback_slot {
195195
head_slot - rollback_slot
196196
} else {
@@ -444,7 +444,7 @@ async fn live_sync_backfill_and_purge(
444444
stats::new_mithril_update(
445445
cfg.chain,
446446
update.tip.slot_or_default(),
447-
live_chain_length(cfg.chain) as u64,
447+
live_chain_length(cfg.chain),
448448
live_chain_head.slot_or_default(),
449449
);
450450

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
/// Default Follower block buffer size.
2323
const DEFAULT_CHAIN_UPDATE_BUFFER_SIZE: usize = 32;
2424

25-
/// How many window (in slot) back from TIP is considered Immutable in the
25+
/// How many window (in slot) back from TIP is considered Immutable in the
2626
/// absence of a mithril snapshot.
2727
const DEFAULT_IMMUTABLE_SLOT_WINDOW: u64 = 12 * 60 * 60;
2828

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ use crate::{
2121
/// Type we use to manage the Sync Task handle map.
2222
type LiveChainBlockList = SkipMap<Point, MultiEraBlock>;
2323

24-
/// Because we have multi-entry relationships in the live-chain, it need to protect it with a
25-
/// `read/write lock`. The underlying `SkipMap` is still capable of multiple simultaneous
26-
/// reads from multiple threads which is the most common access.
24+
/// Because we have multi-entry relationships in the live-chain, it need to protect it
25+
/// with a `read/write lock`. The underlying `SkipMap` is still capable of multiple
26+
/// simultaneous reads from multiple threads which is the most common access.
2727
#[derive(Clone)]
2828
struct ProtectedLiveChainBlockList(Arc<RwLock<LiveChainBlockList>>);
2929

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl ChainUpdate {
4343
/// Is the chain update immutable?
4444
#[must_use]
4545
pub fn immutable(&self) -> bool {
46-
self.data.immutable()
46+
self.data.is_immutable()
4747
}
4848
}
4949

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ mod snapshot_id;
1919
mod stats;
2020
pub mod turbo_downloader;
2121
mod utils;
22-
mod witness;
2322

2423
pub use chain_sync_config::ChainSyncConfig;
2524
pub use chain_update::{ChainUpdate, Kind};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl MithrilSnapshot {
3333
/// Checks if the snapshot contains a given point.
3434
///
3535
/// # Arguments
36-
///
36+
///
3737
/// * `point`: The point to be checked for existence within the specified Mithril
3838
/// snapshot.
3939
///

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

Lines changed: 3 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::{MultiEraBlock, Network, Point, Slot};
1010
use logcall::logcall;
1111
use tokio::task;
1212
use tracing::{debug, error};
@@ -54,10 +54,10 @@ pub(crate) struct MithrilSnapshotIterator {
5454
pub(crate) fn probe_point(point: &Point, distance: u64) -> Point {
5555
// Now that we have the tip, step back about 4 block intervals from tip, and do a fuzzy
5656
// iteration to find the exact two blocks at the end of the immutable chain.
57-
let step_back_search = point.slot_or_default().saturating_sub(distance);
57+
let step_back_search = Slot::from_saturating(point.slot_or_default().into() - distance);
5858

5959
// We stepped back to the origin, so just return Origin
60-
if step_back_search == 0 {
60+
if step_back_search == 0.into() {
6161
return Point::ORIGIN;
6262
}
6363

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::sync::{Arc, LazyLock, RwLock};
44

5-
use cardano_blockchain_types::Network;
5+
use cardano_blockchain_types::{Network, Slot};
66
use chrono::{DateTime, Utc};
77
use dashmap::DashMap;
88
use serde::Serialize;
@@ -142,9 +142,9 @@ pub struct Live {
142142
/// Current Number of Live Blocks
143143
pub blocks: u64,
144144
/// The current head of the live chain slot#
145-
pub head_slot: u64,
145+
pub head_slot: Slot,
146146
/// The current live tip slot# as reported by the peer.
147-
pub tip: u64,
147+
pub tip: Slot,
148148
/// Number of times we connected/re-connected to the Node.
149149
pub reconnects: u64,
150150
/// Last reconnect time,
@@ -312,7 +312,7 @@ pub(crate) fn stats_invalid_block(chain: Network, immutable: bool) {
312312

313313
/// Count the validly deserialized blocks
314314
pub(crate) fn new_live_block(
315-
chain: Network, total_live_blocks: u64, head_slot: u64, tip_slot: u64,
315+
chain: Network, total_live_blocks: u64, head_slot: Slot, tip_slot: Slot,
316316
) {
317317
// This will actually always succeed.
318318
let Some(stats) = lookup_stats(chain) else {

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

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)