@@ -85,8 +85,6 @@ void CLASS::organize(const typename Block::cptr& block,
8585TEMPLATE
8686bool CLASS::handle_event (const code&, chase event_, event_value value) NOEXCEPT
8787{
88- using namespace system ;
89-
9088 if (closed ())
9189 return false ;
9290
@@ -118,13 +116,11 @@ TEMPLATE
118116void CLASS::do_organize (typename Block::cptr block,
119117 const organize_handler& handler) NOEXCEPT
120118{
121- using namespace system ;
122119 BC_ASSERT (stranded ());
123120
124121 // shared_ptr copy keeps block ref in scope until completion of set_code.
125122 const auto & hash = block->get_hash ();
126123 const auto & header = get_header (*block);
127- const auto & query = archive ();
128124
129125 // Skip existing/orphan, get state.
130126 // ........................................................................
@@ -168,6 +164,7 @@ void CLASS::do_organize(typename Block::cptr block,
168164 // Validation and currency.
169165 // ........................................................................
170166
167+ using namespace system ;
171168 if (chain::checkpoint::is_conflict (checkpoints_, hash, height))
172169 {
173170 handler (system::error::checkpoint_conflict, height);
@@ -240,7 +237,7 @@ void CLASS::do_organize(typename Block::cptr block,
240237 auto index = top_candidate;
241238 while (index > branch_point)
242239 {
243- if (!set_reorganized (query. to_candidate (index), index--))
240+ if (!set_reorganized (index--))
244241 {
245242 handler (fault (error::organize5), height);
246243 return ;
@@ -256,7 +253,7 @@ void CLASS::do_organize(typename Block::cptr block,
256253 // Push stored strong headers to candidate chain.
257254 for (const auto & link: std::views::reverse (store_branch))
258255 {
259- if (!set_organized (link, index, is_under_milestone (index++) ))
256+ if (!set_organized (link, index++ ))
260257 {
261258 handler (fault (error::organize6), height);
262259 return ;
@@ -317,8 +314,6 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
317314{
318315 BC_ASSERT (stranded ());
319316
320- using namespace system ;
321-
322317 // Skip already reorganized out, get height.
323318 // ........................................................................
324319
@@ -371,6 +366,7 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
371366 return ;
372367 }
373368
369+ using namespace system ;
374370 const auto & header = get_header (*block);
375371 state.reset (new chain::chain_state{ *state, header, settings_ });
376372 cache (block, state);
@@ -383,7 +379,7 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
383379 const auto top_candidate = state_->height ();
384380 for (auto index = top_candidate; index > fork_point; --index)
385381 {
386- if (!set_reorganized (query. to_candidate (index), index))
382+ if (!set_reorganized (index))
387383 {
388384 fault (error::organize11);
389385 return ;
@@ -399,7 +395,7 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
399395 // Confirmed blocks may or may not be strong, as a branch severs strong
400396 // above the branch point, so as they are copied to the candidate index
401397 // they must be assured to be strong, since the fork point moves up.
402- if (!set_organized (query.to_confirmed (index), index, true ))
398+ if (!set_organized (query.to_confirmed (index), index))
403399 {
404400 fault (error::organize12);
405401 return ;
@@ -427,24 +423,12 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
427423// Private setters
428424// ----------------------------------------------------------------------------
429425
430- // /////////////////////////////////////////////////////////////////////////////
431- // BUGBUG: reorganize/organize operations that span a disk full recovery
432- // BUGBUG: may be inconsistent between set/unset_strong and push/pop_candidate.
433- // /////////////////////////////////////////////////////////////////////////////
434-
435426TEMPLATE
436- bool CLASS::set_reorganized (const database::header_link& link,
437- height_t candidate_height) NOEXCEPT
427+ bool CLASS::set_reorganized (height_t candidate_height) NOEXCEPT
438428{
439429 BC_ASSERT (stranded ());
440- auto & query = archive ();
441-
442- // Any milestone or confirmable candidate block must be set unstrong.
443- const auto milestone = is_under_milestone (candidate_height);
444- const auto strong = milestone || query.is_confirmable (link);
445-
446- // TODO: disk full race.
447- if ((strong && !query.set_unstrong (link)) || !query.pop_candidate ())
430+ BC_ASSERT (!is_under_checkpoint (candidate_height));
431+ if (!archive ().pop_candidate ())
448432 return false ;
449433
450434 fire (events::header_reorganized, candidate_height);
@@ -454,14 +438,10 @@ bool CLASS::set_reorganized(const database::header_link& link,
454438
455439TEMPLATE
456440bool CLASS::set_organized (const database::header_link& link,
457- height_t candidate_height, bool strong ) NOEXCEPT
441+ height_t candidate_height) NOEXCEPT
458442{
459443 BC_ASSERT (stranded ());
460- auto & query = archive ();
461-
462- // TODO: disk full race.
463- // Any milestone or previously-confirmed (strong) block must be set strong.
464- if ((strong && !query.set_strong (link)) || !query.push_candidate (link))
444+ if (!archive ().push_candidate (link))
465445 return false ;
466446
467447 fire (events::header_organized, candidate_height);
@@ -486,7 +466,7 @@ code CLASS::push_block(const Block& block,
486466 if (ec)
487467 return ec;
488468
489- if (!set_organized (link, ctx.height , false ))
469+ if (!set_organized (link, ctx.height ))
490470 return error::organize14;
491471
492472 // events:header_archived | events:block_archived
0 commit comments