Skip to content

Commit e645601

Browse files
committed
fix(cardano-chain-follower): comments
Signed-off-by: bkioshn <[email protected]>
1 parent 1d37012 commit e645601

File tree

4 files changed

+28
-41
lines changed

4 files changed

+28
-41
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl SnapshotData {
2626
}
2727

2828
impl default::Default for SnapshotData {
29-
/// The default snapshot data represents there is no latest snapshot.
29+
/// The default snapshot data represents, there is no latest snapshot.
3030
fn default() -> Self {
3131
SnapshotData {
3232
id: SnapshotId::default(),
@@ -41,7 +41,6 @@ static CURRENT_MITHRIL_SNAPSHOT: LazyLock<DashMap<Network, SnapshotData>> =
4141
/// Get the current latest snapshot data we have recorded.
4242
pub(crate) fn latest_mithril_snapshot_data(chain: Network) -> SnapshotData {
4343
// There should ALWAYS be a snapshot for the chain if this is called.
44-
4544
match CURRENT_MITHRIL_SNAPSHOT.get(&chain) {
4645
Some(snapshot_data) => snapshot_data.value().clone(),
4746
None => SnapshotData::default(),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ const BACKWARD_SEARCH_SLOT_INTERVAL: u64 = 60;
2323

2424
/// Synchronous Inner Iterator state
2525
struct MithrilSnapshotIteratorInner {
26-
/// The chain being iterated
26+
/// The blockchain network being iterated
2727
chain: Network,
28-
/// Where we really want to start iterating from
28+
/// Point we want to start iterating from
2929
start: Point,
3030
/// Previous iteration point.
3131
previous: Point,

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async fn get_latest_snapshots(
7373
Some((latest_snapshot.clone(), chronologically_previous.clone()))
7474
}
7575

76-
/// Given a particular snapshot ID, find the Actual Snapshot for it.
76+
/// Given a particular snapshot ID, find the actual snapshot for it.
7777
async fn get_snapshot_by_id(
7878
client: &Client, network: Network, snapshot_id: &SnapshotId,
7979
) -> Option<SnapshotListItem> {
@@ -205,11 +205,7 @@ async fn download_and_verify_snapshot_certificate(
205205
///
206206
/// # Arguments
207207
///
208-
/// * `network` - The network type for the client to connect to.
209-
/// * `aggregator_url` - A reference to the URL of an aggregator that can be used to
210-
/// create the client.
211-
/// * `genesis_vkey` - The genesis verification key, which is needed to authenticate with
212-
/// the server.
208+
/// * `cfg` - Mithril snapshot configuration.
213209
///
214210
/// # Returns
215211
///
@@ -238,6 +234,7 @@ pub(crate) const MITHRIL_IMMUTABLE_SUB_DIRECTORY: &str = "immutable";
238234
///
239235
/// # Arguments
240236
///
237+
/// * `chain` - The network chain to get the tip block from.
241238
/// * `path` - The path where the immutable chain is stored.
242239
///
243240
/// # Returns
@@ -676,11 +673,8 @@ macro_rules! next_iteration {
676673
/// networks.
677674
/// # Arguments
678675
///
679-
/// * `network` - The network type for the client to connect to.
680-
/// * `aggregator_url` - A reference to the URL of an aggregator that can be used to
681-
/// create the client.
682-
/// * `genesis_vkey` - The genesis verification key, which is needed to authenticate with
683-
/// the server.
676+
/// * `cfg` - The configuration for the Mithril snapshot.
677+
/// * `tx` - The message to be sent when Mithril Snapshot updates.
684678
///
685679
/// # Returns
686680
///

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

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ use cardano_blockchain_types::{Network, Point};
1111
use tracing::debug;
1212

1313
use crate::mithril_snapshot_sync::{get_mithril_tip, MITHRIL_IMMUTABLE_SUB_DIRECTORY};
14-
/// A Representation of a Snapshot Path and its represented Immutable File Number.
14+
/// A representation of a Snapshot Path and its represented immutable file number.
1515
#[derive(Clone, Debug)]
1616
pub(crate) struct SnapshotId {
17-
/// The Snapshot Path
17+
/// The snapshot path
1818
path: PathBuf,
19-
/// The largest Immutable File Number
19+
/// The largest immutable file number
2020
file: u64,
21-
/// The Tip of the Snapshot
21+
/// The tip of the Snapshot
2222
tip: Point,
2323
}
2424

2525
impl SnapshotId {
26-
/// See if we can Parse the path into an immutable file number.
26+
/// See if we can parse the path into an immutable file number.
2727
pub(crate) fn parse_path(path: &Path) -> Option<u64> {
2828
// Path must actually exist, and be a directory.
2929
if !path.is_dir() {
@@ -42,7 +42,7 @@ impl SnapshotId {
4242
}
4343

4444
/// Try and create a new `SnapshotID` from a given path.
45-
/// Immutable TIP must be provided.
45+
/// Immutable tip must be provided.
4646
pub(crate) fn new(path: &Path, tip: Point) -> Option<Self> {
4747
debug!("Trying to Get SnapshotID of: {}", path.to_string_lossy());
4848
let immutable_file = SnapshotId::parse_path(path)?;
@@ -56,7 +56,7 @@ impl SnapshotId {
5656
}
5757

5858
/// Try and create a new `SnapshotID` from a given path.
59-
/// Includes properly getting the Immutable TIP.
59+
/// Includes properly getting the immutable TIP.
6060
pub(crate) async fn try_new(chain: Network, path: &Path) -> Option<Self> {
6161
let Ok(tip) = get_mithril_tip(chain, path).await else {
6262
return None;
@@ -65,28 +65,28 @@ impl SnapshotId {
6565
SnapshotId::new(path, tip.point())
6666
}
6767

68-
/// Get the Immutable Blockchain path from this `SnapshotId`
68+
/// Get the immutable blockchain path from this `SnapshotId`
6969
pub(crate) fn immutable_path(&self) -> PathBuf {
7070
let mut immutable = self.path.clone();
7171
immutable.push(MITHRIL_IMMUTABLE_SUB_DIRECTORY);
7272

7373
immutable
7474
}
7575

76-
/// Get the Blockchain path from this `SnapshotId`
76+
/// Get the blockchain path from this `SnapshotId`
7777
pub(crate) fn path(&self) -> PathBuf {
7878
self.path.clone()
7979
}
8080

81-
/// Get the Blockchain path from this `SnapshotId` only if it actually exists.
81+
/// Get the blockchain path from this `SnapshotId` only if it actually exists.
8282
pub(crate) fn path_if_exists(&self) -> Option<PathBuf> {
8383
if self.tip.is_unknown() {
8484
return None;
8585
}
8686
Some(self.path.clone())
8787
}
8888

89-
/// Get the Tip of the Immutable Blockchain from this `SnapshotId`
89+
/// Get the tip of the immutable blockchain from this `SnapshotId`
9090
pub(crate) fn tip(&self) -> Point {
9191
self.tip.clone()
9292
}
@@ -122,27 +122,24 @@ impl Display for SnapshotId {
122122
}
123123
}
124124

125-
// Normal Comparisons to simplify code.
125+
// Normal comparisons to simplify code.
126126
impl PartialEq for SnapshotId {
127-
// Equality ONLY checks the Immutable File Number, not the path.
128-
// This is because the Filename is already the ImmutableFileNumber
127+
// Equality ONLY checks the `file` (immutable file number), not the path.
129128
fn eq(&self, other: &Self) -> bool {
130129
self.file == other.file
131130
}
132131
}
133132

134133
impl PartialOrd for SnapshotId {
135-
// Equality ONLY checks the Immutable File Number, not the path.
136-
// This is because the Filename is already the ImmutableFileNumber
134+
// Equality ONLY checks the `file` (immutable file number), not the path.
137135
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
138136
self.file.partial_cmp(&other.file)
139137
}
140138
}
141139

142-
// Allows us to compare a SnapshotID against Some(SnapshotID).
140+
// Allows us to compare a `SnapshotID` against Some(`SnapshotID`).
143141
impl PartialEq<Option<SnapshotId>> for SnapshotId {
144-
// Equality ONLY checks the Immutable File Number, not the path.
145-
// This is because the Filename is already the ImmutableFileNumber
142+
// Equality ONLY checks the `file` (immutable file number), not the path.
146143
fn eq(&self, other: &Option<Self>) -> bool {
147144
match other {
148145
None => false,
@@ -152,8 +149,7 @@ impl PartialEq<Option<SnapshotId>> for SnapshotId {
152149
}
153150

154151
impl PartialOrd<Option<SnapshotId>> for SnapshotId {
155-
// Equality ONLY checks the Immutable File Number, not the path.
156-
// This is because the Filename is already the ImmutableFileNumber
152+
// Equality ONLY checks the `file` (immutable file number), not the path.
157153
fn partial_cmp(&self, other: &Option<Self>) -> Option<Ordering> {
158154
match other {
159155
None => Some(Ordering::Greater), // Anything is always greater than None.
@@ -162,18 +158,16 @@ impl PartialOrd<Option<SnapshotId>> for SnapshotId {
162158
}
163159
}
164160

165-
// Allows us to compare a SnapshotID against u64 (Just the Immutable File Number).
161+
// Allows us to compare a `SnapshotID` against u64 (just the immutable file number).
166162
impl PartialEq<u64> for SnapshotId {
167-
// Equality ONLY checks the Immutable File Number, not the path.
168-
// This is because the Filename is already the ImmutableFileNumber
163+
// Equality ONLY checks the `file` (immutable file number), not the path.
169164
fn eq(&self, other: &u64) -> bool {
170165
self.file == *other
171166
}
172167
}
173168

174169
impl PartialOrd<u64> for SnapshotId {
175-
// Equality ONLY checks the Immutable File Number, not the path.
176-
// This is because the Filename is already the ImmutableFileNumber
170+
// Equality ONLY checks the `file` (immutable file number), not the path.
177171
fn partial_cmp(&self, other: &u64) -> Option<Ordering> {
178172
self.file.partial_cmp(other)
179173
}

0 commit comments

Comments
 (0)