Skip to content

Commit

Permalink
Add rule fork transition logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Mar 11, 2024
1 parent d32b5cc commit 8381e84
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/chasers/chaser_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,27 @@ void chaser_header::do_disorganize(header_t header) NOEXCEPT

const auto& coin = config().bitcoin;
const auto top_candidate = top_state_->height();
const auto top_forks = top_state_->forks();
top_state_ = query.get_candidate_chain_state(coin, fork_point);
if (!top_state_)
{
close(error::store_integrity);
return;
}

// TODO: this could be moved to deconfirmation.
const auto fork_forks = top_state_->forks();
if (top_forks != fork_forks)
{
const binary prev{ to_bits(sizeof(forks)), to_big_endian(top_forks) };
const binary next{ to_bits(sizeof(forks)), to_big_endian(fork_forks) };
LOGN("Rules unforked from ["
<< prev << "] at candidate height ("
<< top_candidate << ") to ["
<< next << "] at confirmed block ["
<< fork_point << ":" << encode_hash(top_state_->hash()) << "].");
}

// Copy candidates from above fork point to top into header tree.
// ------------------------------------------------------------------------

Expand Down Expand Up @@ -250,9 +264,24 @@ void chaser_header::do_organize(const header::cptr& header_ptr,
}

// Roll chain state forward from previous to current header.
// ------------------------------------------------------------------------

const auto prev_forks = state->forks();
state.reset(new chain_state{ *state, header, coin });
const auto next_forks = state->forks();
const auto height = state->height();

// TODO: this could be moved to confirmation.
if (prev_forks != next_forks)
{
const binary prev{ to_bits(sizeof(forks)), to_big_endian(prev_forks) };
const binary next{ to_bits(sizeof(forks)), to_big_endian(next_forks) };
LOGN("Rules forked from ["
<< prev << "] to ["
<< next << "] at candidate block ["
<< height << ":" << encode_hash(hash) << "].");
}

// Check/Accept header.
// ------------------------------------------------------------------------
// Header validations are not bypassed when under checkpoint/milestone.
Expand Down

0 comments on commit 8381e84

Please sign in to comment.