diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 819f29ba9e..8eed9c896a 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -3613,10 +3614,20 @@ struct controller_impl { } ); }; - if (b->is_proper_svnn_block()) { - return fork_db.apply_s>(f); + // always return a valid future + auto unlinkable = [&](const auto&) -> std::future { + std::packaged_task task( [b, id]() -> block_handle { + EOS_ASSERT( false, unlinkable_block_exception, + "unlinkable block ${id} previous ${p} not in fork db", ("id", id)("p", b->previous) ); + } ); + task(); + return task.get_future(); + }; + + if (!b->is_proper_svnn_block()) { + return fork_db.apply>(f, unlinkable); } - return fork_db.apply_l>(f); + return fork_db.apply>(unlinkable, f); } // thread safe, expected to be called from thread other than the main thread @@ -3635,10 +3646,10 @@ struct controller_impl { return create_block_state_i( id, b, *prev ); }; - if (b->is_proper_svnn_block()) { - return fork_db.apply_s>(f); + if (!b->is_proper_svnn_block()) { + return fork_db.apply_l>(f); } - return fork_db.apply_l>(f); + return fork_db.apply_s>(f); } // expected to be called from application thread as it modifies bsp->valid_qc and if_irreversible_block_id