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
22 changes: 11 additions & 11 deletions src/chasers/chaser_confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT
// Set before if not using prevout table.
if (!prevout_ && !query.set_strong(link))
{
fault(error::confirm5);
fault(error::confirm2);
return;
}

Expand Down Expand Up @@ -242,14 +242,14 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT

if (!query.set_block_confirmable(link))
{
fault(error::confirm4);
fault(error::confirm3);
return;
}

// Set after if using prevout table.
if (prevout_ && !query.set_strong(link))
{
fault(error::confirm5);
fault(error::confirm4);
return;
}
}
Expand All @@ -258,7 +258,7 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT
// Set in either case.
if (!query.set_strong(link))
{
fault(error::confirm6);
fault(error::confirm5);
return;
}
}
Expand All @@ -271,21 +271,21 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT
// database::error::block_confirmable [resurrected state]
// database::error::block_unconfirmable [shouldn't be here]
// database::error::unknown_state [shouldn't be here]
fault(error::confirm7);
fault(error::confirm6);
return;
}

if (!query.set_filter_head(link))
{
fault(error::confirm8);
fault(error::confirm7);
return;
}

if (!set_organized(link, height))
{
fault(error::confirm9);
return;
}
////if (!set_organized(link, height))
////{
//// fault(error::confirm8);
//// return;
////}

set_position(height);

Expand Down
16 changes: 9 additions & 7 deletions src/protocols/protocol_block_in_31800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,16 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
// Commit block.txs.
// ........................................................................

// This must not be a reference to the shared pointer, as otherwise the
// shared_ptr may be taken out of scope before the tx write completes.
// set_code() uses weak references to many elements of the transaction ref.
const auto txs_ptr = block->transactions_ptr();
const auto size = block->serialized_size(true);
// IMPORTANT: ~block() releases all memory for parts of itself, as a
// consequence of the custom memory allocator. Therefore, while shared_ptr
// to an element of the block would normally be valid after ~block(), the
// object pointed to will have been deallocated by ~block(). Therefore a
// reference to `block` must be passed to set_code (i.e. not a copy of or
// reference to `lock->transactions_ptr()`.

// This invokes set_strong when checked.
if (const auto code = query.set_code(*txs_ptr, link, size, checked))
const auto bytes = block->serialized_size(true);
if (const auto code = query.set_code(*block, link, checked, bytes))
{
LOGF("Failure storing block [" << encode_hash(hash) << ":" << height
<< "] from [" << authority() << "] " << code.message());
Expand All @@ -376,7 +378,7 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
notify(ec, chase::checked, height);
fire(events::block_archived, height);

count(size);
count(bytes);
map_->erase(it);
if (is_idle())
{
Expand Down
Loading