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_header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class BCN_API chaser_header
height_t candidate_height) NOEXCEPT;
code push_header(const system::hash_digest& key) NOEXCEPT;
code push_header(const system::chain::header& header,
const system::chain::context& ctx, bool milestone) NOEXCEPT;
const system::chain::context& ctx, const uint256_t& work,
bool milestone) NOEXCEPT;
void cache(const system::chain::header::cptr& header,
const chain_state::cptr& state) NOEXCEPT;

Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ enum error_t : uint8_t
confirm11,
confirm12,
transaction1,
transaction2,
estimates_initialize,
estimates_push1,
estimates_push2,
Expand Down
10 changes: 6 additions & 4 deletions src/chasers/chaser_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ void chaser_header::do_organize(const header::cptr& header_ptr,
}

// Push new header as top of candidate chain.
if (const auto ec = push_header(header, state->context(), milestone))
if (const auto ec = push_header(header, state->context(),
state->cumulative_work(), milestone))
{
handler(fault(ec), height);
return;
Expand Down Expand Up @@ -627,11 +628,11 @@ bool chaser_header::set_organized(const header_link& link,
// Milestone is archived in the header and like checkpoint cannot change.
// But unlike checkpointed, milestoned blocks may not be strong chain.
code chaser_header::push_header(const header& header, const context& ctx,
bool milestone) NOEXCEPT
const uint256_t& work, bool milestone) NOEXCEPT
{
auto& query = archive();
header_link link{};
const auto ec = query.set_code(link, header, ctx, milestone, false);
const auto ec = query.set_code(link, header, ctx, work, milestone, false);
if (ec)
return ec;

Expand All @@ -648,7 +649,8 @@ code chaser_header::push_header(const hash_digest& key) NOEXCEPT

const auto& header_ptr = handle.mapped();
const auto& state = header_ptr->get_state();
return push_header(*header_ptr, state->context(), false);
return push_header(*header_ptr, state->context(),
state->cumulative_work(), false);
}

void chaser_header::cache(const header::cptr& header,
Expand Down
19 changes: 18 additions & 1 deletion src/chasers/chaser_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,39 @@ void chaser_transaction::do_submit(const transactions_cptr& txs, bool test,
}

auto& query = archive();
database::tx_links fresh(txs->size(), database::tx_link::terminal);
for (index = {}; index < txs->size(); ++index)
{
bool pooled{};
database::tx_link link{};
const auto& tx = *txs->at(index);

// Disk full may leave package partly archived, resolves by resubmit.
if (const auto ec = query.set_code(link, tx))
if (const auto ec = query.set_code(link, pooled, tx))
{
handler(fault(ec), index);
return;
}

if (!pooled)
fresh.at(index) = link;

fire(events::tx_archived, to_rate(tx));
notify(error::success, chases::transaction{ link });
}

// Package parents are resolved by hash, so the whole package precedes.
for (index = {}; index < txs->size(); ++index)
{
const database::tx_link link{ fresh.at(index) };
if (!link.is_terminal() &&
!query.set_tx_state(link, *txs->at(index), pool_))
{
handler(fault(error::transaction2), index);
return;
}
}

handler(error::success, {});
}

Expand Down
1 change: 1 addition & 0 deletions src/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ DEFINE_ERROR_T_MESSAGE_MAP(error)
{ confirm11, "confirm11" },
{ confirm12, "confirm12" },
{ transaction1, "transaction1" },
{ transaction2, "transaction2" },
{ estimates_initialize, "estimates_initialize" },
{ estimates_push1, "estimates_push1" },
{ estimates_push2, "estimates_push2" },
Expand Down
2 changes: 1 addition & 1 deletion test/functional/p2p_setup_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ struct p2p_unassociated_setup_fixture
inline p2p_unassociated_setup_fixture()
: p2p_setup_fixture([](node::query& query)
{
return query.set(unassociated(), database::context{}, false);
return query.set(unassociated(), database::context{}, {}, false);
}, [](configuration& config)
{
config.network.enable_not_found = true;
Expand Down
Loading