Skip to content

Commit

Permalink
Fix crashes by guessing shelley_trans_epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewWestberg committed Oct 7, 2024
1 parent d12761b commit 41fa137
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 69 deletions.
83 changes: 37 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cncli"
version = "6.4.0"
version = "6.4.1"
authors = ["Andrew Westberg <[email protected]>"]
edition = "2021"
build = "build.rs"
Expand Down
40 changes: 18 additions & 22 deletions src/nodeclient/leaderlog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,17 +752,17 @@ pub(crate) fn status(db_path: &Path, byron_genesis: &Path, shelley_genesis: &Pat
match read_shelley_genesis(shelley_genesis) {
Ok(shelley) => {
debug!("{:?}", shelley);
let shelley_trans_epoch = match *shelley_trans_epoch {
None => guess_shelley_transition_epoch(shelley.network_magic),
Some(value) => value,
};
match block_store.get_tip_slot_number() {
Ok(tip_slot_number) => {
debug!("tip_slot_number: {}", tip_slot_number);
let tip_time = slot_to_naivedatetime(
&byron,
&shelley,
tip_slot_number,
shelley_trans_epoch.expect("infallible"),
)
.and_utc()
.timestamp();
let tip_time =
slot_to_naivedatetime(&byron, &shelley, tip_slot_number, shelley_trans_epoch)
.and_utc()
.timestamp();
let system_time = Utc::now().timestamp();
if system_time - tip_time < 120 {
print_status_synced();
Expand Down Expand Up @@ -810,22 +810,18 @@ pub(crate) fn send_slots(
match block_store.get_tip_slot_number() {
Ok(tip_slot_number) => {
debug!("tip_slot_number: {}", tip_slot_number);
let tip_time = slot_to_naivedatetime(
&byron,
&shelley,
tip_slot_number,
shelley_trans_epoch.expect("infallible"),
)
.and_utc()
.timestamp();
let shelley_trans_epoch = match *shelley_trans_epoch {
None => guess_shelley_transition_epoch(shelley.network_magic),
Some(value) => value,
};
let tip_time =
slot_to_naivedatetime(&byron, &shelley, tip_slot_number, shelley_trans_epoch)
.and_utc()
.timestamp();
let system_time = Utc::now().timestamp();
if system_time - tip_time < 120 {
let (epoch, _) = get_first_slot_of_epoch(
&byron,
&shelley,
tip_slot_number,
shelley_trans_epoch.expect("infallible"),
);
let (epoch, _) =
get_first_slot_of_epoch(&byron, &shelley, tip_slot_number, shelley_trans_epoch);
debug!("epoch: {}", epoch);
for pool in pooltool_config.pools.iter() {
match block_store.get_current_slots(epoch, &pool.pool_id) {
Expand Down

0 comments on commit 41fa137

Please sign in to comment.