@@ -41,6 +41,7 @@ using namespace std::chrono;
4141using namespace std ::placeholders;
4242
4343// arbitrary testing (const).
44+
4445void executor::read_test (bool dump) const
4546{
4647 using namespace database ;
@@ -809,18 +810,29 @@ void executor::read_test(bool dump) const
809810 logger (format (" STOP (%1% secs)" ) % span.count ());
810811}
811812
812-
813813// TODO: create a block/tx dumper.
814814void executor::read_test (bool ) const
815815{
816- constexpr auto hash511280 = base16_hash (
817- " 00000000000000000030b12ee5a31aaf553f49cdafa52698f70f0f0706f46d3d" );
818-
816+ constexpr auto link = 600' 000_size;
819817 const auto start = logger::now ();
820- const auto link = query_.to_header (hash511280);
821- if (link.is_terminal ())
818+
819+ const auto height = query_.get_height (link);
820+ if (height.is_terminal ())
821+ {
822+ logger (" height.is_terminal()" );
823+ return ;
824+ }
825+
826+ if (height != link)
827+ {
828+ logger (" height != link" );
829+ return ;
830+ }
831+
832+ code ec{};
833+ if ((ec = query_.block_confirmable (link)))
822834 {
823- logger (" link.is_terminal() " );
835+ logger (format ( " query_.block_confirmable: %1% " ) % ec. message () );
824836 return ;
825837 }
826838
@@ -855,24 +867,36 @@ void executor::read_test(bool) const
855867 state.timestamp = block->header ().timestamp ();
856868 state.minimum_block_version = 0 ;
857869 state.work_required = 0 ;
870+
871+ if (!block->populate (state))
872+ {
873+ logger (" !block->populate(state)" );
874+ return ;
875+ }
876+
858877 if (!query_.populate (*block))
859878 {
860879 logger (" !query_.populate(*block)" );
861880 return ;
862881 }
863882
864- code ec{};
865883 if ((ec = block->check ()))
866884 {
867- logger (format (" Block check: %1%" ) % ec.message ());
885+ logger (format (" Block check(): %1%" ) % ec.message ());
886+ return ;
887+ }
888+
889+ if ((ec = block->check (state)))
890+ {
891+ logger (format (" Block check(state): %1%" ) % ec.message ());
868892 return ;
869893 }
870894
871- const auto & coin = metadata_. configured . bitcoin ;
872- if ((ec = block-> accept (state, coin .subsidy_interval_blocks ,
873- coin .initial_subsidy ())))
895+ if ((ec = block-> accept (state,
896+ metadata_. configured . bitcoin .subsidy_interval_blocks ,
897+ metadata_. configured . bitcoin .initial_subsidy ())))
874898 {
875- logger (format (" Block accept: %1%" ) % ec.message ());
899+ logger (format (" Block accept(state) : %1%" ) % ec.message ());
876900 return ;
877901 }
878902
@@ -882,8 +906,39 @@ void executor::read_test(bool) const
882906 return ;
883907 }
884908
909+ logger (format (" segregated [%1%]" ) % to_int (block->is_segregated ()));
910+ logger (format (" segregated count [%1%]" ) % block->segregated ());
911+
885912 const auto span = duration_cast<milliseconds>(logger::now () - start);
886- logger (format (" Validated block 511280 in %1% msec." ) % span.count ());
913+ logger (format (" Validated block [%1%] in %2% msec." ) % link % span.count ());
914+
915+ // //constexpr auto tx_hash = base16_hash(
916+ // // "eb2179db6c40bceb02cebcc5c99cf783ed6385b00767c7a5419fe530eaba8bff");
917+ // //const auto tx_link = query_.to_tx(tx_hash);
918+ // //const auto tx = query_.get_transaction(tx_link);
919+ // //const auto result = query_.populate(*tx);
920+ // //const auto size = tx->serialized_size(false);
921+ // //const auto weight = tx->serialized_size(true);
922+ // //const auto version = tx->version();
923+ // //const auto locktime = tx->locktime();
924+ // //const auto fee = tx->fee();
925+ // //const auto sequence = tx->inputs_ptr()->at(0)->sequence();
926+ // //const auto& in = tx->inputs_ptr()->at(0)->script();
927+ // //const auto& out = tx->inputs_ptr()->at(0)->prevout->script();
928+ // //const auto connect = tx->connect(state);
929+
930+ // //logger(format("tx_hash [%1%]") % encode_hash(tx_hash));
931+ // //logger(format("tx_link [%1%]") % tx_link.value);
932+ // //logger(format("result [%1%]") % to_int(result));
933+ // //logger(format("size [%1%]") % size);
934+ // //logger(format("weight [%1%]") % weight);
935+ // //logger(format("version [%1%]") % version);
936+ // //logger(format("locktime [%1%]") % locktime);
937+ // //logger(format("fee [%1%]") % fee);
938+ // //logger(format("sequence [%1%]") % sequence);
939+ // //logger(format("in [%1%]") % in.to_string(chain::flags::no_rules));
940+ // //logger(format("out [%1%]") % out.to_string(chain::flags::no_rules));
941+ // //logger(format("connect [%1%]") % connect.message());
887942}
888943
889944#endif // UNDEFINED
0 commit comments