Skip to content

Commit a020cdd

Browse files
authored
Merge pull request #902 from evoskuil/master
Add handle_get_address_confirmed/unconfirmed/balance.
2 parents 31e1553 + 4c40521 commit a020cdd

File tree

12 files changed

+176
-87
lines changed

12 files changed

+176
-87
lines changed

console/executor.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class executor
109109
bool do_slabs();
110110
bool do_buckets();
111111
bool do_collisions();
112-
bool do_read();
113-
bool do_write();
112+
bool do_read(const system::hash_digest& hash);
113+
bool do_write(const system::hash_digest& hash);
114114

115115
// Runtime options.
116116
void do_hot_backup();
@@ -126,8 +126,8 @@ class executor
126126
void subscribe_capture();
127127

128128
// Built in tests.
129-
void read_test(bool dump) const;
130-
void write_test(bool dump);
129+
void read_test(const system::hash_digest& hash) const;
130+
void write_test(const system::hash_digest& hash);
131131

132132
// Logging.
133133
database::file::stream::out::rotator create_log_sink() const;

console/executor_commands.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,26 +168,26 @@ bool executor::do_collisions()
168168
}
169169

170170
// --[t]read
171-
bool executor::do_read()
171+
bool executor::do_read(const system::hash_digest& hash)
172172
{
173173
log_.stop();
174174
if (!check_store_path() ||
175175
!open_store())
176176
return false;
177177

178-
read_test(true);
178+
read_test(hash);
179179
return close_store();
180180
}
181181

182182
// --[w]rite
183-
bool executor::do_write()
183+
bool executor::do_write(const system::hash_digest& hash)
184184
{
185185
log_.stop();
186186
if (!check_store_path() ||
187187
!open_store())
188188
return false;
189189

190-
write_test(true);
190+
write_test(hash);
191191
return close_store();
192192
}
193193

@@ -210,6 +210,9 @@ bool executor::dispatch()
210210
if (config.backup)
211211
return do_backup();
212212

213+
if (config.restore)
214+
return do_restore();
215+
213216
if (config.hardware)
214217
return do_hardware();
215218

@@ -228,20 +231,17 @@ bool executor::dispatch()
228231
if (config.information)
229232
return do_information();
230233

231-
if (config.test)
232-
return do_read();
233-
234234
if (config.settings)
235235
return do_settings();
236236

237237
if (config.version)
238238
return do_version();
239239

240-
if (config.write)
241-
return do_write();
240+
if (config.test != system::null_hash)
241+
return do_read(config.test);
242242

243-
if (config.restore)
244-
return do_restore();
243+
if (config.write != system::null_hash)
244+
return do_write(config.write);
245245

246246
return do_run();
247247
}

console/executor_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void executor::do_menu() const
197197
// [t]est
198198
void executor::do_test() const
199199
{
200-
read_test(false);
200+
read_test(system::null_hash);
201201
}
202202

203203
// [w]ork

console/executor_test_reader.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using namespace network;
3131
using namespace system;
3232

3333
// arbitrary testing (const).
34-
void executor::read_test(bool) const
34+
void executor::read_test(const hash_digest&) const
3535
{
3636
logger(format("Point table body searches: %1% / (%2% + %1%)") %
3737
store_.point.positive_search_count() %
@@ -40,11 +40,12 @@ void executor::read_test(bool) const
4040

4141
#if defined(UNDEFINED)
4242

43-
void executor::read_test(bool dump) const
43+
void executor::read_test(const hash_digest&) const
4444
{
4545
using namespace database;
4646
constexpr auto start_tx = 1'000'000_u32;
4747
constexpr auto target_count = 100_size;
48+
constexpr auto dump{ false };
4849

4950
// Set ensures unique addresses.
5051
std::set<hash_digest> keys{};
@@ -271,15 +272,15 @@ void executor::read_test(bool dump) const
271272
}
272273
}
273274

274-
void executor::read_test(bool) const
275+
void executor::read_test(const hash_digest&) const
275276
{
276277
database::header_link link{ 350'017_u32 };
277278
const auto ec = query_.block_confirmable(link);
278279
logger(format("block_confirmable [%1%] at height [%2%].") % ec.message() %
279280
query_.get_height(link));
280281
}
281282

282-
void executor::read_test(bool dump) const
283+
void executor::read_test(const hash_digest&) const
283284
{
284285
logger("Wire size computation.");
285286
const auto start = fine_clock::now();
@@ -310,7 +311,7 @@ void executor::read_test(bool dump) const
310311
size % last % span.count());
311312
}
312313

313-
void executor::read_test(bool dump) const
314+
void executor::read_test(const hash_digest&) const
314315
{
315316
auto start = fine_clock::now();
316317
auto count = query_.header_records();
@@ -350,7 +351,7 @@ void executor::read_test(bool dump) const
350351
logger(format("Top strong tx is [%1%] in [%2%] ms.") % sub1(tx) % span.count());
351352
}
352353

353-
void executor::read_test(bool dump) const
354+
void executor::read_test(const hash_digest&) const
354355
{
355356
const auto from = 481'824_u32;
356357
const auto top = 840'000_u32; ////query_.get_top_associated();
@@ -376,7 +377,7 @@ void executor::read_test(bool dump) const
376377
% total % top % average % span.count());
377378
}
378379

379-
void executor::read_test(bool dump) const
380+
void executor::read_test(const hash_digest&) const
380381
{
381382
// Binance wallet address with 1,380,169 transaction count.
382383
// blockstream.info/address/bc1qm34lsc65zpw79lxes69zkqmk6ee3ewf0j77s3h
@@ -398,7 +399,7 @@ void executor::read_test(bool dump) const
398399
// This was caused by concurrent redundant downloads at tail following restart.
399400
// The earlier transactions were marked as confirmed and during validation the
400401
// most recent are found via point.hash association priot to to_block() test.
401-
void executor::read_test(bool dump) const
402+
void executor::read_test(const hash_digest&) const
402403
{
403404
const auto height = 839'287_size;
404405
const auto block = query_.to_confirmed(height);
@@ -570,7 +571,7 @@ void executor::read_test(bool dump) const
570571
logger(format("Confirm [%1%] test (%2%).") % height % ec.message());
571572
}
572573

573-
void executor::read_test(bool dump) const
574+
void executor::read_test(const hash_digest&) const
574575
{
575576
const auto bk_link = query_.to_candidate(804'001_size);
576577
const auto block = query_.get_block(bk_link);
@@ -627,7 +628,7 @@ void executor::read_test(bool dump) const
627628
logger(format("Confirm test 2 complete (%1%).") % ec.message());
628629
}
629630

630-
void executor::read_test(bool dump) const
631+
void executor::read_test(const hash_digest&) const
631632
{
632633
using namespace database;
633634
constexpr auto frequency = 100'000u;
@@ -683,7 +684,7 @@ void executor::read_test(bool dump) const
683684
logger(format("get_transaction" BN_READ_ROW) % tx % span.count());
684685
}
685686

686-
void executor::read_test(bool dump) const
687+
void executor::read_test(const hash_digest&) const
687688
{
688689
constexpr auto hash492224 = base16_hash(
689690
"0000000000000000003277b639e56dffe2b4e60d18aeedb1fe8b7e4256b2a526");
@@ -806,7 +807,7 @@ void executor::read_test(bool dump) const
806807
}
807808

808809
// TODO: create a block/tx dumper.
809-
void executor::read_test(bool) const
810+
void executor::read_test(const hash_digest&) const
810811
{
811812
constexpr auto link = 600'000_size;
812813
const auto start = logger::now();

console/executor_test_writer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ using namespace network;
3030
using namespace system;
3131

3232
// arbitrary testing (non-const).
33-
void executor::write_test(bool)
33+
void executor::write_test(const hash_digest&)
3434
{
3535
logger("No write test implemented.");
3636
}
3737

3838
#if defined(UNDEFINED)
3939

40-
void executor::write_test(bool)
40+
void executor::write_test(const system::hash_digest&)
4141
{
4242
for (database::header_link link{ 793'008_u32 }; link < 885'000_u32; ++link)
4343
{
@@ -51,7 +51,7 @@ void executor::write_test(bool)
5151
logger(format("set_block_unknown complete."));
5252
}
5353

54-
void executor::write_test(bool)
54+
void executor::write_test(const system::hash_digest&)
5555
{
5656
code ec{};
5757
size_t count{};
@@ -97,7 +97,7 @@ void executor::write_test(bool)
9797
span.count());
9898
}
9999

100-
void executor::write_test(bool)
100+
void executor::write_test(const system::hash_digest&)
101101
{
102102
using namespace database;
103103
constexpr auto frequency = 10'000;
@@ -134,7 +134,7 @@ void executor::write_test(bool)
134134
logger(format("block" BN_WRITE_ROW) % height % span.count());
135135
}
136136

137-
void executor::write_test(bool)
137+
void executor::write_test(const system::hash_digest&)
138138
{
139139
using namespace database;
140140
////constexpr uint64_t fees = 99;
@@ -201,7 +201,7 @@ void executor::write_test(bool)
201201
logger(format("block" BN_WRITE_ROW) % height % span.count());
202202
}
203203

204-
void executor::write_test(bool)
204+
void executor::write_test(const system::hash_digest&)
205205
{
206206
constexpr auto hash251684 = base16_hash(
207207
"00000000000000720e4c59ad28a8b61f38015808e92465e53111e3463aed80de");

include/bitcoin/node/configuration.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class BCN_API configuration
5555
bool collisions{};
5656

5757
/// Ad-hoc Testing.
58-
bool test{};
59-
bool write{};
58+
system::config::hash256 test{};
59+
system::config::hash256 write{};
6060

6161
/// Settings.
6262
log::settings log;

include/bitcoin/node/protocols/protocol_explore.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_EXPLORE_HPP
2020
#define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_EXPLORE_HPP
2121

22+
#include <atomic>
2223
#include <memory>
2324
#include <optional>
2425
#include <bitcoin/node/define.hpp>
@@ -95,7 +96,7 @@ class BCN_API protocol_explore
9596
bool handle_get_tx(const code& ec, interface::tx,
9697
uint8_t version, uint8_t media, const system::hash_cptr& hash,
9798
bool witness) NOEXCEPT;
98-
bool handle_get_tx_block(const code& ec, interface::tx_block,
99+
bool handle_get_tx_header(const code& ec, interface::tx_header,
99100
uint8_t version, uint8_t media,
100101
const system::hash_cptr& hash) NOEXCEPT;
101102
bool handle_get_tx_fee(const code& ec, interface::tx_fee,
@@ -152,6 +153,7 @@ class BCN_API protocol_explore
152153
const std::optional<system::hash_cptr>& hash) NOEXCEPT;
153154

154155
dispatcher dispatcher_{};
156+
std::atomic_bool stopping_{};
155157
};
156158

157159
} // namespace node

src/parse/target.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ code parse_target(request_t& out, const std::string_view& path) NOEXCEPT
199199
else
200200
{
201201
const auto component = segments[segment++];
202-
if (component == "block")
203-
method = "tx_block";
202+
if (component == "header")
203+
method = "tx_header";
204204
else if (component == "fee")
205205
method = "tx_fee";
206206
else

src/parser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,14 @@ options_metadata parser::load_options() THROWS
256256
// Ad-hoc Testing.
257257
(
258258
BN_READ_VARIABLE ",t",
259-
value<bool>(&configured.test)->
260-
default_value(false)->zero_tokens(),
259+
value<config::hash256>(&configured.test)->
260+
default_value(system::null_hash),
261261
"Run built-in read test and display."
262262
)
263263
(
264264
BN_WRITE_VARIABLE ",w",
265-
value<bool>(&configured.write)->
266-
default_value(false)->zero_tokens(),
265+
value<config::hash256>(&configured.write)->
266+
default_value(system::null_hash),
267267
"Run built-in write test and display."
268268
);
269269

0 commit comments

Comments
 (0)