diff --git a/src/chasers/chaser_confirm.cpp b/src/chasers/chaser_confirm.cpp index 1afca87fc..cd69296b3 100644 --- a/src/chasers/chaser_confirm.cpp +++ b/src/chasers/chaser_confirm.cpp @@ -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; } @@ -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; } } @@ -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; } } @@ -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); diff --git a/src/protocols/protocol_block_in_31800.cpp b/src/protocols/protocol_block_in_31800.cpp index d9110abe0..68fc6847b 100644 --- a/src/protocols/protocol_block_in_31800.cpp +++ b/src/protocols/protocol_block_in_31800.cpp @@ -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()); @@ -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()) {