Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion include/bitcoin/node/chasers/chaser_block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class BCN_API chaser_block

private:
void set_prevout(const system::chain::input& input) const NOEXCEPT;
bool populate(const system::chain::block& block) const NOEXCEPT;
bool populate(const system::chain::block& block,
const system::chain::context& ctx) const NOEXCEPT;

private:
// These are thread safe.
Expand Down
3 changes: 1 addition & 2 deletions include/bitcoin/node/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ enum error_t : uint8_t
confirm9,
confirm10,
confirm11,
confirm12,
confirm13
confirm12
};

// No current need for error_code equivalence mapping.
Expand Down
7 changes: 4 additions & 3 deletions src/chasers/chaser_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ code chaser_block::validate(const block& block,
if (((ec = block.check())) || ((ec = block.check(ctx))))
return ec;

if (!populate(block))
if (!populate(block, ctx))
return system::error::missing_previous_output;

if ((ec = block.accept(ctx,
Expand Down Expand Up @@ -204,9 +204,10 @@ void chaser_block::set_prevout(const input& input) const NOEXCEPT
}

// Populate prevouts from self/tree/store (without metadata).
bool chaser_block::populate(const block& block) const NOEXCEPT
bool chaser_block::populate(const block& block,
const chain::context& ctx) const NOEXCEPT
{
block.populate();
block.populate(ctx);

const auto& ins = *block.inputs_ptr();
std::ranges::for_each(ins, [&](const auto& in) NOEXCEPT
Expand Down
18 changes: 6 additions & 12 deletions src/chasers/chaser_confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,29 +279,23 @@ void chaser_confirm::organize(header_states& fork, const header_links& popped,
handle_event(error::success, chase::bump, height_t{});
}

bool chaser_confirm::confirm_block(const header_link& link,
size_t height, const header_links& popped, size_t fork_point) NOEXCEPT
bool chaser_confirm::confirm_block(const header_link& link, size_t height,
const header_links& popped, size_t fork_point) NOEXCEPT
{
BC_ASSERT(stranded());
auto& query = archive();

if (const auto ec = query.block_confirmable(link))
{
if (!query.set_unstrong(link))
{
fault(error::confirm9);
return false;
}

if (!query.set_block_unconfirmable(link))
{
fault(error::confirm10);
fault(error::confirm9);
return false;
}

if (!roll_back(popped, fork_point, sub1(height)))
{
fault(error::confirm11);
fault(error::confirm10);
return false;
}

Expand All @@ -311,13 +305,13 @@ bool chaser_confirm::confirm_block(const header_link& link,
// Before set_block_confirmable.
if (!query.set_filter_head(link))
{
fault(error::confirm12);
fault(error::confirm11);
return false;
}

if (!query.set_block_confirmable(link))
{
fault(error::confirm13);
fault(error::confirm12);
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/chasers/chaser_validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,15 @@ code chaser_validate::populate(bool bypass, const chain::block& block,
if (bypass)
{
// Populating for filters only (no validation metadata required).
block.populate();
block.populate(ctx);
if (!query.populate_without_metadata(block))
return system::error::missing_previous_output;
}
else
{
// Internal maturity and time locks are verified here because they are
// the only necessary confirmation checks for internal spends.
if (const auto ec = block.populate_with_metadata(ctx))
if (const auto ec = block.populate(ctx))
return ec;

// Metadata identifies internal spends alowing confirmation bypass.
Expand Down
3 changes: 1 addition & 2 deletions src/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ DEFINE_ERROR_T_MESSAGE_MAP(error)
{ confirm9, "confirm9" },
{ confirm10, "confirm10" },
{ confirm11, "confirm11" },
{ confirm12, "confirm12" },
{ confirm13, "confirm13" }
{ confirm12, "confirm12" }
};

DEFINE_ERROR_T_CATEGORY(error, "node", "node code")
Expand Down