Skip to content

Commit d94f265

Browse files
authored
Merge pull request #691 from evoskuil/master
Incorporate new validation/confirmation settings, clean up
2 parents 9fb5c26 + aef7f62 commit d94f265

20 files changed

+367
-344
lines changed

.vscode/settings.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
{
2-
<<<<<<< HEAD
3-
"cmake.sourceDirectory": "/home/nixmini/Repository/Source/libbitcoin-node/builds/cmake",
4-
"cmake.useCMakePresets": "always"
5-
}
6-
=======
72
"cmake.sourceDirectory": "${workspaceFolder}/builds/cmake",
83
"cmake.useCMakePresets": "always"
94
}
10-
>>>>>>> e3e1a43d (Regenerate artifacts.)

builds/vscode/node.code-workspace

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
<<<<<<< HEAD
32
"folders": [
43
{
54
"path": "../../../libbitcoin-system"
@@ -13,14 +12,6 @@
1312
{
1413
"path": "../../../libbitcoin-node"
1514
}
16-
],
17-
"settings": {}
18-
=======
19-
"folders": [
20-
{
21-
"path": "../../../libbitcoin-node"
22-
}
2315
],
2416
"settings": {}
25-
>>>>>>> e3e1a43d (Regenerate artifacts.)
2617
}

include/bitcoin/node/chasers/chaser.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ class BCN_API chaser
4343

4444
/// Should be called from node strand.
4545
virtual code start() NOEXCEPT = 0;
46+
47+
/// Override to capture non-blocking stopping.
48+
virtual void stopping(const code& ec) NOEXCEPT;
49+
50+
/// Override to capture blocking stop.
51+
virtual void stop() NOEXCEPT;
4652

4753
protected:
4854
/// Abstract base class protected construct.
@@ -68,10 +74,6 @@ class BCN_API chaser
6874
/// Methods.
6975
/// -----------------------------------------------------------------------
7076

71-
/// Override to capture node stopping, allow full_node to invoke.
72-
friend full_node;
73-
virtual void stopping(const code& ec) NOEXCEPT;
74-
7577
/// Node threadpool is stopped and may still be joining.
7678
virtual bool closed() const NOEXCEPT;
7779

include/bitcoin/node/chasers/chaser_confirm.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class BCN_API chaser_confirm
4040
chaser_confirm(full_node& node) NOEXCEPT;
4141

4242
code start() NOEXCEPT override;
43+
void stopping(const code& ec) NOEXCEPT override;
44+
void stop() NOEXCEPT override;
4345

4446
protected:
4547
using header_links = std_vector<database::header_link>;
@@ -51,7 +53,8 @@ class BCN_API chaser_confirm
5153
virtual void do_validated(height_t height) NOEXCEPT;
5254
virtual void do_reorganize(size_t height) NOEXCEPT;
5355
virtual void do_organize(size_t height) NOEXCEPT;
54-
virtual bool enqueue_block(const database::header_link& link) NOEXCEPT;
56+
57+
virtual void enqueue_block(const database::header_link& link) NOEXCEPT;
5558
virtual void confirm_tx(const database::context& ctx,
5659
const database::tx_link& link, const race::ptr& racer) NOEXCEPT;
5760
virtual void handle_tx(const code& ec, const database::tx_link& tx,
@@ -82,6 +85,9 @@ class BCN_API chaser_confirm
8285
bool get_is_strong(bool& strong, const uint256_t& fork_work,
8386
size_t fork_point) const NOEXCEPT;
8487

88+
// This is thread safe.
89+
const bool concurrent_;
90+
8591
// These are protected by strand.
8692
network::threadpool threadpool_;
8793
header_links popped_{};

include/bitcoin/node/chasers/chaser_snapshot.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,31 @@ class BCN_API chaser_snapshot
4040
code start() NOEXCEPT override;
4141

4242
protected:
43-
virtual void do_confirm(height_t height) NOEXCEPT;
4443
virtual void do_archive(height_t height) NOEXCEPT;
44+
virtual void do_valid(height_t height) NOEXCEPT;
45+
virtual void do_confirm(height_t height) NOEXCEPT;
4546
virtual bool handle_event(const code& ec, chase event_,
4647
event_value value) NOEXCEPT;
4748

4849
private:
4950
bool update_bytes() NOEXCEPT;
5051
bool update_valid(height_t height) NOEXCEPT;
52+
bool update_confirm(height_t height) NOEXCEPT;
5153
void do_snapshot(height_t height) NOEXCEPT;
5254

5355
// These are thread safe.
5456
const size_t top_checkpoint_;
55-
const size_t snapshot_valid_;
5657
const uint64_t snapshot_bytes_;
57-
const bool enabled_valid_;
58+
const size_t snapshot_valid_;
59+
const size_t snapshot_confirm_;
5860
const bool enabled_bytes_;
61+
const bool enabled_valid_;
62+
const bool enabled_confirm_;
5963

6064
// These are protected by strand.
6165
uint64_t bytes_{};
6266
size_t valid_{};
67+
size_t confirm_{};
6368
};
6469

6570
} // namespace node

include/bitcoin/node/chasers/chaser_validate.hpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,22 @@ class BCN_API chaser_validate
3939
chaser_validate(full_node& node) NOEXCEPT;
4040

4141
code start() NOEXCEPT override;
42-
43-
/// Validate a populated candidate block.
44-
virtual void validate(const system::chain::block::cptr& block,
45-
const database::header_link& link, size_t height) NOEXCEPT;
42+
void stopping(const code& ec) NOEXCEPT override;
43+
void stop() NOEXCEPT override;
4644

4745
protected:
4846
typedef network::race_unity<const code&, const database::tx_link&> race;
4947

5048
virtual bool handle_event(const code& ec, chase event_,
5149
event_value value) NOEXCEPT;
5250

53-
virtual void do_validate(const system::chain::block::cptr& block,
54-
database::header_link::integer link, size_t height) NOEXCEPT;
55-
5651
virtual void do_regressed(height_t branch_point) NOEXCEPT;
5752
virtual void do_checked(height_t height) NOEXCEPT;
5853
virtual void do_bump(height_t height) NOEXCEPT;
5954

60-
virtual bool enqueue_block(const database::header_link& link) NOEXCEPT;
61-
virtual void validate_tx(const database::context& ctx,
62-
const database::tx_link& link, const race::ptr& racer) NOEXCEPT;
63-
virtual void handle_tx(const code& ec, const database::tx_link& tx,
64-
const race::ptr& racer) NOEXCEPT;
65-
virtual void handle_txs(const code& ec, const database::tx_link& tx,
66-
const database::header_link& link,
67-
const database::context& ctx) NOEXCEPT;
68-
virtual void validate_block(const code& ec,
69-
const database::header_link& link,
70-
const database::context& ctx) NOEXCEPT;
55+
virtual void validate_block(const database::header_link& link) NOEXCEPT;
56+
virtual void complete_block(const code& ec,
57+
const database::header_link& link, size_t height) NOEXCEPT;
7158

7259
private:
7360
// neutrino
@@ -78,12 +65,16 @@ class BCN_API chaser_validate
7865
const system::chain::block& block) NOEXCEPT;
7966

8067
// These are thread safe.
68+
const bool prepopulate_;
69+
const bool concurrent_;
70+
const size_t maximum_backlog_;
8171
const uint64_t initial_subsidy_;
82-
const uint32_t subsidy_interval_blocks_;
72+
const uint32_t subsidy_interval_;
8373

8474
// These are protected by strand.
8575
network::threadpool threadpool_;
8676
system::hash_digest neutrino_{};
77+
size_t validation_backlog_{};
8778
};
8879

8980
} // namespace node

include/bitcoin/node/impl/chasers/chaser_organize.ipp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ bool CLASS::handle_event(const code&, chase event_, event_value value) NOEXCEPT
8989
if (closed())
9090
return false;
9191

92+
// TODO: allow required messages.
93+
////// Stop generating query during suspension.
94+
////if (suspended())
95+
//// return true;
96+
9297
switch (event_)
9398
{
9499
case chase::unchecked:
@@ -195,7 +200,7 @@ void CLASS::do_organize(typename Block::cptr block,
195200
bool strong{};
196201
uint256_t work{};
197202
hashes tree_branch{};
198-
size_t branch_point{};
203+
height_t branch_point{};
199204
header_links store_branch{};
200205

201206
if (!get_branch_work(work, branch_point, tree_branch, store_branch, header))

include/bitcoin/node/settings.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,20 @@ class BCN_API settings
7373

7474
/// Properties.
7575
bool headers_first;
76+
bool priority_validation;
77+
bool concurrent_validation;
78+
bool concurrent_confirmation;
7679
float allowed_deviation;
7780
uint16_t allocation_multiple;
7881
uint64_t snapshot_bytes;
7982
uint32_t snapshot_valid;
83+
uint32_t snapshot_confirm;
8084
uint32_t maximum_height;
8185
uint32_t maximum_concurrency;
8286
uint16_t sample_period_seconds;
8387
uint32_t currency_window_minutes;
8488
uint32_t threads;
89+
bool prepopulate;
8590

8691
/// Helpers.
8792
virtual size_t maximum_height_() const NOEXCEPT;

src/chasers/chaser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ void chaser::stopping(const code&) NOEXCEPT
4747
{
4848
}
4949

50+
void chaser::stop() NOEXCEPT
51+
{
52+
}
53+
5054
bool chaser::closed() const NOEXCEPT
5155
{
5256
return node_.closed();

src/chasers/chaser_check.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ bool chaser_check::handle_event(const code&, chase event_,
9595
if (closed())
9696
return false;
9797

98+
// TODO: allow required messages.
99+
////// Stop generating query during suspension.
100+
////if (suspended())
101+
//// return true;
102+
98103
switch (event_)
99104
{
100105
// Track downloaded.
@@ -365,14 +370,15 @@ size_t chaser_check::set_unassociated() NOEXCEPT
365370
size_t chaser_check::get_inventory_size() const NOEXCEPT
366371
{
367372
// Either condition means blocks shouldn't be getting downloaded (yet).
368-
const auto peers = config().network.outbound_connections;
373+
const size_t peers = config().network.outbound_connections;
369374
if (is_zero(peers) || !is_current())
370375
return zero;
371376

372377
const auto& query = archive();
373378
const auto fork = query.get_fork();
374-
const auto window = config().node.maximum_concurrency_();
375-
const auto step = std::min(window, messages::max_inventory);
379+
380+
const auto span = system::ceilinged_multiply(messages::max_inventory, peers);
381+
const auto step = std::min(maximum_concurrency_, span);
376382
const auto inventory = query.get_unassociated_count_above(fork, step);
377383
return system::ceilinged_divide(inventory, peers);
378384
}

0 commit comments

Comments
 (0)