Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Log] Changes to epoch hash. #2420

Merged
merged 6 commits into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ledger/src/advance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,16 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {

// If the block is the start of a new epoch, or the epoch hash has not been set, update the current epoch hash.
if block.height() % N::NUM_BLOCKS_PER_EPOCH == 0 || self.current_epoch_hash.read().is_none() {
// Update the current epoch hash.
self.current_epoch_hash.write().clone_from(&self.get_epoch_hash(block.height()).ok());
// Update and log the current epoch hash.
match self.get_epoch_hash(block.height()).ok() {
Some(epoch_hash) => {
trace!("Updating the current epoch hash at block {} to '{epoch_hash}'", block.height());
*self.current_epoch_hash.write() = Some(epoch_hash);
}
None => {
error!("Failed to update the current epoch hash at block {}", block.height());
}
}
}

Ok(())
Expand Down