Skip to content

Commit

Permalink
Merge pull request #700 from evoskuil/master
Browse files Browse the repository at this point in the history
Change read query, comments.
  • Loading branch information
evoskuil authored Dec 12, 2024
2 parents 9af3dcc + e044c76 commit 05508f9
Showing 1 changed file with 49 additions and 10 deletions.
59 changes: 49 additions & 10 deletions console/executor_test_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ using namespace system;
using namespace std::chrono;
using namespace std::placeholders;

#if defined(UNDEFINED)

void executor::read_test(bool dump) const
{
constexpr auto start_tx = 1'000'000'000_u32;
using namespace database;
constexpr auto start_tx = 1'000'000_u32;
constexpr auto target_count = 100_size;

// Set ensures unique addresses.
Expand All @@ -58,7 +57,10 @@ void executor::read_test(bool dump) const
{
const auto outputs = query_.get_outputs(tx++);
if (outputs->empty())
{
// fault, tx with no outputs.
return;
}

for (const auto& put: *outputs)
{
Expand Down Expand Up @@ -96,37 +98,66 @@ void executor::read_test(bool dump) const

std_vector<out> outs{};
outs.reserve(target_count);
using namespace database;

start = fine_clock::now();
for (auto& key: keys)
{
if (cancel_)
return;

size_t found{};
auto address_it = store_.address.it(key);
if (cancel_ || address_it.self().is_terminal())
if (address_it.self().is_terminal())
{
// fault, missing address.
return;
}

do
{
if (cancel_)
break;

table::address::record address{};
if (cancel_ || !store_.address.get(address_it.self(), address))
if (!store_.address.get(address_it.self(), address))
{
// fault, missing address.
return;
}

const auto out_fk = address.output_fk;
table::output::get_parent output{};
if (!store_.output.get(out_fk, output))
{
// fault, missing output.
return;
}

const auto tx_fk = output.parent_fk;
if (!store_.tx.exists(query_.get_tx_key(tx_fk)))
{
// fault, missing tx.
return;
}

// There may be not-strong txs but we just won't count those.
const auto block_fk = query_.to_block(tx_fk);
if (block_fk.is_terminal())
continue;

table::header::get_height header{};
if (!store_.header.get(block_fk, header))
{
// fault, missing block.
return;
}

table::txs::get_position txs{ {}, tx_fk };
if (!store_.txs.get(query_.to_txs(block_fk), txs))
{
// fault, missing txs.
return;
}

spend_link sp_fk{};
input_link in_fk{};
Expand All @@ -139,7 +170,10 @@ void executor::read_test(bool dump) const
sp_fk = spenders.front();
table::spend::record spend{};
if (!store_.spend.get(sp_fk, spend))
{
// fault, missing spender.
return;
}

in_fk = spend.input_fk;
sp_tx_fk = spend.parent_fk;
Expand Down Expand Up @@ -170,8 +204,9 @@ void executor::read_test(bool dump) const
}
while (address_it.advance());

logger(format("Fetched [%1%] unique payments to address [%2%].") %
found% encode_hash(key));
// This affects the clock, so disabled.
////logger(format("Fetched [%1%] unique payments to address [%2%].") %
//// found % encode_hash(key));
}

span = duration_cast<milliseconds>(fine_clock::now() - start);
Expand Down Expand Up @@ -205,7 +240,8 @@ void executor::read_test(bool dump) const

for (const auto& row: outs)
{
if (cancel_) break;
if (cancel_)
break;

const auto output = !row.output ? "{error}" :
row.output->script().to_string(chain::flags::all_rules);
Expand Down Expand Up @@ -235,6 +271,8 @@ void executor::read_test(bool dump) const
}
}

#if defined(UNDEFINED)

// arbitrary testing (const).
void executor::read_test(bool dump) const
{
Expand Down Expand Up @@ -763,7 +801,6 @@ void executor::read_test(bool dump) const
logger(format("STOP (%1% secs)") % span.count());
}

#endif // UNDEFINED

// TODO: create a block/tx dumper.
void executor::read_test(bool) const
Expand Down Expand Up @@ -841,5 +878,7 @@ void executor::read_test(bool) const
logger(format("Validated block 511280 in %1% msec.") % span.count());
}

#endif // UNDEFINED

} // namespace node
} // namespace libbitcoin

0 comments on commit 05508f9

Please sign in to comment.