Skip to content

Commit

Permalink
Merge a656ff4 into 5a7d8d3
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Mar 16, 2024
2 parents 5a7d8d3 + a656ff4 commit c222d3a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
54 changes: 54 additions & 0 deletions include/bitcoin/database/impl/query/context.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,32 @@ bool CLASS::get_candidate_timestamp(uint32_t& time, size_t height,
return get_timestamp(time, to_candidate(height));
}

TEMPLATE
bool CLASS::populate_candidate_bip9(chain_state::data& data,
const chain_state::map& map, const header& header,
size_t header_height) const NOEXCEPT
{
if (map.bip9_bit0_height != chain_state::map::unrequested)
{
if (header_height == map.bip9_bit0_height)
data.bip9_bit0_hash = header.hash();
else
data.bip9_bit0_hash = get_header_key(
to_candidate(map.bip9_bit0_height));
}

if (map.bip9_bit1_height != chain_state::map::unrequested)
{
if (header_height == map.bip9_bit1_height)
data.bip9_bit1_hash = header.hash();
else
data.bip9_bit1_hash = get_header_key(
to_candidate(map.bip9_bit1_height));
}

return true;
}

TEMPLATE
bool CLASS::populate_candidate_work(chain_state::data& data,
const header& header, size_t header_height) const NOEXCEPT
Expand Down Expand Up @@ -170,6 +196,7 @@ bool CLASS::populate_candidate_all(chain_state::data& data,

return !link.is_terminal() &&
populate_candidate_work(data, header, height) &&
populate_confirmed_bip9(data, map, header, height) &&
populate_candidate_bits(data, map, header, height) &&
populate_candidate_versions(data, map, header, height) &&
populate_candidate_timestamps(data, map, header, height);
Expand Down Expand Up @@ -254,6 +281,32 @@ bool CLASS::get_confirmed_timestamp(uint32_t& time, size_t height,
return get_timestamp(time, to_confirmed(height));
}

TEMPLATE
bool CLASS::populate_confirmed_bip9(chain_state::data& data,
const chain_state::map& map, const header& header,
size_t header_height) const NOEXCEPT
{
if (map.bip9_bit0_height != chain_state::map::unrequested)
{
if (header_height == map.bip9_bit0_height)
data.bip9_bit0_hash = header.hash();
else
data.bip9_bit0_hash = get_header_key(
to_confirmed(map.bip9_bit0_height));
}

if (map.bip9_bit1_height != chain_state::map::unrequested)
{
if (header_height == map.bip9_bit1_height)
data.bip9_bit1_hash = header.hash();
else
data.bip9_bit1_hash = get_header_key(
to_confirmed(map.bip9_bit1_height));
}

return true;
}

TEMPLATE
bool CLASS::populate_confirmed_work(chain_state::data& data,
const header& header, size_t header_height) const NOEXCEPT
Expand Down Expand Up @@ -345,6 +398,7 @@ bool CLASS::populate_confirmed_all(chain_state::data& data,

return !link.is_terminal() &&
populate_confirmed_work(data, header, height) &&
populate_confirmed_bip9(data, map, header, height) &&
populate_confirmed_bits(data, map, header, height) &&
populate_confirmed_versions(data, map, header, height) &&
populate_confirmed_timestamps(data, map, header, height);
Expand Down
10 changes: 10 additions & 0 deletions include/bitcoin/database/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ class query
bool get_candidate_timestamp(uint32_t& time, size_t height,
const header& header, size_t header_height) const NOEXCEPT;

// This is currently based on archived activation only.
bool populate_candidate_bip9(chain_state::data& data,
const chain_state::map& map, const header& header,
size_t header_height) const NOEXCEPT;

bool populate_candidate_work(chain_state::data& data, const header& header,
size_t header_height) const NOEXCEPT;
bool populate_candidate_bits(chain_state::data& data,
Expand All @@ -434,6 +439,11 @@ class query
bool get_confirmed_timestamp(uint32_t& time, size_t height,
const header& header, size_t header_height) const NOEXCEPT;

// This is currently based on archived activation only.
bool populate_confirmed_bip9(chain_state::data& data,
const chain_state::map& map, const header& header,
size_t header_height) const NOEXCEPT;

bool populate_confirmed_work(chain_state::data& data, const header& header,
size_t header_height) const NOEXCEPT;
bool populate_confirmed_bits(chain_state::data& data,
Expand Down

0 comments on commit c222d3a

Please sign in to comment.