Skip to content

Commit cbe8f86

Browse files
committed
fix(cardano-chain-follower): revert changes
Signed-off-by: bkioshn <[email protected]>
1 parent d970fdb commit cbe8f86

15 files changed

+340
-349
lines changed

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

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async fn start_sync_for(network: &Network, matches: ArgMatches) -> Result<(), Bo
114114
cfg.mithril_cfg = cfg.mithril_cfg.with_dl_config(dl_config);
115115

116116
info!(
117-
network = cfg.network.to_string(),
117+
chain = cfg.chain.to_string(),
118118
mithril_sync_dl_workers = mithril_dl_workers,
119119
mithril_sync_dl_chunk_size = mithril_dl_chunk_size,
120120
mithril_sync_dl_queue_ahead = mithril_dl_queue_ahead,
@@ -137,49 +137,49 @@ const RUNNING_UPDATE_INTERVAL: u64 = 100_000;
137137
/// Try and follow a chain continuously, from Genesis until Tip.
138138
#[allow(clippy::too_many_lines)]
139139
async fn follow_for(network: Network, matches: ArgMatches) {
140-
info!(network = network.to_string(), "Following");
140+
info!(chain = network.to_string(), "Following");
141141
let mut follower = ChainFollower::new(network, Point::ORIGIN, Point::TIP).await;
142142

143-
let is_all_tip_blocks = matches.get_flag("all-tip-blocks");
144-
let is_all_live_blocks = matches.get_flag("all-live-blocks");
145-
let is_stop_at_tip = matches.get_flag("stop-at-tip");
146-
let is_halt_on_error = matches.get_flag("halt-on-error");
147-
let is_log_raw_aux = matches.get_flag("log-raw-aux");
143+
let all_tip_blocks = matches.get_flag("all-tip-blocks");
144+
let all_live_blocks = matches.get_flag("all-live-blocks");
145+
let stop_at_tip = matches.get_flag("stop-at-tip");
146+
let halt_on_error = matches.get_flag("halt-on-error");
147+
let log_raw_aux = matches.get_flag("log-raw-aux");
148148

149149
// Metadata
150-
let is_log_bad_cip36 = matches.get_flag("log-bad-cip36");
150+
let log_bad_cip36 = matches.get_flag("log-bad-cip36");
151151

152152
let mut current_era = String::new();
153153
let mut last_update: Option<ChainUpdate> = None;
154-
let mut is_last_update_shown = false;
154+
let mut last_update_shown = false;
155155
let mut prev_hash: Option<pallas_crypto::hash::Hash<32>> = None;
156-
let mut is_last_immutable: bool = false;
157-
let mut is_reached_tip = false; // After we reach TIP we show all block we process.
156+
let mut last_immutable: bool = false;
157+
let mut reached_tip = false; // After we reach TIP we show all block we process.
158158
let mut updates: u64 = 0;
159159
let mut last_fork: Fork = 0.into();
160-
let mut is_follow_all = false;
160+
let mut follow_all = false;
161161

162162
let mut last_metrics_time = Instant::now();
163163

164164
while let Some(chain_update) = follower.next().await {
165165
updates += 1;
166166

167167
if chain_update.tip {
168-
is_reached_tip = true;
168+
reached_tip = true;
169169
}
170170

171171
let block = chain_update.block_data().decode();
172172
let this_era = block.era().to_string();
173173

174174
// When we transition between important points, show the last block as well.
175175
if ((current_era != this_era)
176-
|| (chain_update.is_immutable() != is_last_immutable)
176+
|| (chain_update.immutable() != last_immutable)
177177
|| (last_fork != chain_update.data.fork()))
178-
&& !is_last_update_shown
178+
&& !last_update_shown
179179
{
180180
if let Some(last_update) = last_update.clone() {
181181
info!(
182-
network = network.to_string(),
182+
chain = network.to_string(),
183183
"Chain Update {}:{}",
184184
updates - 1,
185185
last_update
@@ -188,29 +188,29 @@ async fn follow_for(network: Network, matches: ArgMatches) {
188188
}
189189

190190
// If these become true, we will show all blocks from the follower.
191-
is_follow_all = is_follow_all
192-
|| (!chain_update.is_immutable() && is_all_live_blocks)
193-
|| ((chain_update.data.fork() > 1.into()) && is_all_tip_blocks);
191+
follow_all = follow_all
192+
|| (!chain_update.immutable() && all_live_blocks)
193+
|| ((chain_update.data.fork() > 1.into()) && all_tip_blocks);
194194

195195
// Don't know if this update will show or not, so say it didn't.
196-
is_last_update_shown = false;
196+
last_update_shown = false;
197197

198198
if (current_era != this_era)
199-
|| (chain_update.is_immutable() != is_last_immutable)
200-
|| is_reached_tip
201-
|| is_follow_all
199+
|| (chain_update.immutable() != last_immutable)
200+
|| reached_tip
201+
|| follow_all
202202
|| (updates % RUNNING_UPDATE_INTERVAL == 0)
203203
|| (last_fork != chain_update.data.fork())
204204
{
205205
current_era = this_era;
206-
is_last_immutable = chain_update.is_immutable();
206+
last_immutable = chain_update.immutable();
207207
last_fork = chain_update.data.fork();
208208
info!(
209-
network = network.to_string(),
209+
chain = network.to_string(),
210210
"Chain Update {updates}:{}", chain_update
211211
);
212212
// We already showed the last update, no need to show it again.
213-
is_last_update_shown = true;
213+
last_update_shown = true;
214214
}
215215

216216
let this_prev_hash = block.header().previous_hash();
@@ -226,42 +226,42 @@ async fn follow_for(network: Network, matches: ArgMatches) {
226226
"This Can't Happen".to_string()
227227
};
228228
error!(
229-
network = network.to_string(),
229+
chain = network.to_string(),
230230
"Chain is broken: {chain_update} Does not follow: {display_last_update}",
231231
);
232232
break;
233233
}
234234

235-
if is_log_raw_aux {
235+
if log_raw_aux {
236236
if let Some(x) = block.as_alonzo() {
237237
info!(
238-
network = network.to_string(),
238+
chain = network.to_string(),
239239
"Raw Aux Data: {:02x?}", x.auxiliary_data_set
240240
);
241241
} else if let Some(x) = block.as_babbage() {
242242
info!(
243-
network = network.to_string(),
243+
chain = network.to_string(),
244244
"Raw Aux Data: {:02x?}", x.auxiliary_data_set
245245
);
246246
} else if let Some(x) = block.as_conway() {
247247
info!(
248-
network = network.to_string(),
248+
chain = network.to_string(),
249249
"Raw Aux Data: {:02x?}", x.auxiliary_data_set
250250
);
251251
}
252252
}
253253

254254
// Illustrate how the chain-follower works with metadata.
255255
// Log bad CIP36.
256-
if is_log_bad_cip36 {
256+
if log_bad_cip36 {
257257
log_bad_cip36_info(chain_update.block_data(), network);
258258
}
259259
// TODO - Add CIP509 example.
260260

261261
prev_hash = Some(block.hash());
262262
last_update = Some(chain_update);
263263

264-
if is_reached_tip && is_stop_at_tip {
264+
if reached_tip && stop_at_tip {
265265
break;
266266
}
267267

@@ -273,7 +273,7 @@ async fn follow_for(network: Network, matches: ArgMatches) {
273273

274274
info!("Json Metrics: {}", stats.as_json(true));
275275

276-
if is_halt_on_error
276+
if halt_on_error
277277
&& (stats.mithril.download_or_validation_failed > 0
278278
|| stats.mithril.failed_to_get_tip > 0
279279
|| stats.mithril.tip_did_not_advance > 0
@@ -285,19 +285,16 @@ async fn follow_for(network: Network, matches: ArgMatches) {
285285
}
286286
}
287287

288-
if !is_last_update_shown {
288+
if !last_update_shown {
289289
if let Some(last_update) = last_update.clone() {
290-
info!(
291-
network = network.to_string(),
292-
"Last Update: {}", last_update
293-
);
290+
info!(chain = network.to_string(), "Last Update: {}", last_update);
294291
}
295292
}
296293

297294
let stats = Statistics::new(network);
298295
info!("Json Metrics: {}", stats.as_json(true));
299296

300-
info!(network = network.to_string(), "Following Completed.");
297+
info!(chain = network.to_string(), "Following Completed.");
301298
}
302299

303300
/// Function for logging bad CIP36.

0 commit comments

Comments
 (0)