@@ -40,11 +40,10 @@ using namespace system;
4040using namespace std ::chrono;
4141using namespace std ::placeholders;
4242
43- #if defined(UNDEFINED)
44-
4543void executor::read_test (bool dump) const
4644{
47- constexpr auto start_tx = 1'000'000' 000_u32;
45+ using namespace database ;
46+ constexpr auto start_tx = 1'000' 000_u32;
4847 constexpr auto target_count = 100_size;
4948
5049 // Set ensures unique addresses.
@@ -58,7 +57,10 @@ void executor::read_test(bool dump) const
5857 {
5958 const auto outputs = query_.get_outputs (tx++);
6059 if (outputs->empty ())
60+ {
61+ // fault, tx with no outputs.
6162 return ;
63+ }
6264
6365 for (const auto & put: *outputs)
6466 {
@@ -96,37 +98,66 @@ void executor::read_test(bool dump) const
9698
9799 std_vector<out> outs{};
98100 outs.reserve (target_count);
99- using namespace database ;
100101
101102 start = fine_clock::now ();
102103 for (auto & key: keys)
103104 {
105+ if (cancel_)
106+ return ;
107+
104108 size_t found{};
105109 auto address_it = store_.address .it (key);
106- if (cancel_ || address_it.self ().is_terminal ())
110+ if (address_it.self ().is_terminal ())
111+ {
112+ // fault, missing address.
107113 return ;
114+ }
108115
109116 do
110117 {
118+ if (cancel_)
119+ break ;
120+
111121 table::address::record address{};
112- if (cancel_ || !store_.address .get (address_it.self (), address))
122+ if (!store_.address .get (address_it.self (), address))
123+ {
124+ // fault, missing address.
113125 return ;
126+ }
114127
115128 const auto out_fk = address.output_fk ;
116129 table::output::get_parent output{};
117130 if (!store_.output .get (out_fk, output))
131+ {
132+ // fault, missing output.
118133 return ;
134+ }
119135
120136 const auto tx_fk = output.parent_fk ;
137+ if (!store_.tx .exists (query_.get_tx_key (tx_fk)))
138+ {
139+ // fault, missing tx.
140+ return ;
141+ }
142+
143+ // There may be not-strong txs but we just won't count those.
121144 const auto block_fk = query_.to_block (tx_fk);
145+ if (block_fk.is_terminal ())
146+ continue ;
122147
123148 table::header::get_height header{};
124149 if (!store_.header .get (block_fk, header))
150+ {
151+ // fault, missing block.
125152 return ;
153+ }
126154
127155 table::txs::get_position txs{ {}, tx_fk };
128156 if (!store_.txs .get (query_.to_txs (block_fk), txs))
157+ {
158+ // fault, missing txs.
129159 return ;
160+ }
130161
131162 spend_link sp_fk{};
132163 input_link in_fk{};
@@ -139,7 +170,10 @@ void executor::read_test(bool dump) const
139170 sp_fk = spenders.front ();
140171 table::spend::record spend{};
141172 if (!store_.spend .get (sp_fk, spend))
173+ {
174+ // fault, missing spender.
142175 return ;
176+ }
143177
144178 in_fk = spend.input_fk ;
145179 sp_tx_fk = spend.parent_fk ;
@@ -170,8 +204,9 @@ void executor::read_test(bool dump) const
170204 }
171205 while (address_it.advance ());
172206
173- logger (format (" Fetched [%1%] unique payments to address [%2%]." ) %
174- found% encode_hash (key));
207+ // This affects the clock, so disabled.
208+ // //logger(format("Fetched [%1%] unique payments to address [%2%].") %
209+ // // found % encode_hash(key));
175210 }
176211
177212 span = duration_cast<milliseconds>(fine_clock::now () - start);
@@ -205,7 +240,8 @@ void executor::read_test(bool dump) const
205240
206241 for (const auto & row: outs)
207242 {
208- if (cancel_) break ;
243+ if (cancel_)
244+ break ;
209245
210246 const auto output = !row.output ? " {error}" :
211247 row.output ->script ().to_string (chain::flags::all_rules);
@@ -235,6 +271,8 @@ void executor::read_test(bool dump) const
235271 }
236272}
237273
274+ #if defined(UNDEFINED)
275+
238276// arbitrary testing (const).
239277void executor::read_test (bool dump) const
240278{
@@ -763,7 +801,6 @@ void executor::read_test(bool dump) const
763801 logger (format (" STOP (%1% secs)" ) % span.count ());
764802}
765803
766- #endif // UNDEFINED
767804
768805// TODO: create a block/tx dumper.
769806void executor::read_test (bool ) const
@@ -841,5 +878,7 @@ void executor::read_test(bool) const
841878 logger (format (" Validated block 511280 in %1% msec." ) % span.count ());
842879}
843880
881+ #endif // UNDEFINED
882+
844883} // namespace node
845884} // namespace libbitcoin
0 commit comments