Skip to content

Commit 3176f9f

Browse files
authored
Merge pull request #776 from evoskuil/master
Redesign organize/confirm around updated queries.
2 parents 2b1f7cb + d6fe058 commit 3176f9f

File tree

9 files changed

+264
-258
lines changed

9 files changed

+264
-258
lines changed

include/bitcoin/node/chasers/chaser_block.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class BCN_API chaser_block
4646

4747
/// Query store for const pointer to Block instance by candidate height.
4848
bool get_block(system::chain::block::cptr& out,
49-
size_t height) const NOEXCEPT override;
49+
const header_link& link) const NOEXCEPT override;
5050

5151
/// Determine if Block is a duplicate (success for not duplicate).
5252
code duplicate(size_t& height,

include/bitcoin/node/chasers/chaser_confirm.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class BCN_API chaser_confirm
4242
protected:
4343
using header_link = database::header_link;
4444
using header_links = database::header_links;
45+
using header_states = database::header_states;
4546

4647
virtual bool handle_event(const code& ec, chase event_,
4748
event_value value) NOEXCEPT;
@@ -51,12 +52,13 @@ class BCN_API chaser_confirm
5152
virtual void do_bumped(height_t height) NOEXCEPT;
5253
virtual void do_bump(height_t height) NOEXCEPT;
5354

54-
virtual void reorganize(header_links& fork, size_t fork_point) NOEXCEPT;
55-
virtual void organize(header_links& fork, const header_links& popped,
55+
virtual void reorganize(header_states& fork, size_t top,
56+
size_t fork_point) NOEXCEPT;
57+
virtual void organize(header_states& fork, const header_links& popped,
5658
size_t fork_point) NOEXCEPT;
5759
virtual bool confirm_block(const header_link& link,
5860
size_t height, const header_links& popped, size_t fork_point) NOEXCEPT;
59-
virtual void complete_block(const code& ec, const header_link& link,
61+
virtual bool complete_block(const code& ec, const header_link& link,
6062
size_t height, bool bypassed) NOEXCEPT;
6163

6264
private:

include/bitcoin/node/chasers/chaser_header.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class BCN_API chaser_header
4949

5050
/// Query store for const pointer to Block instance by candidate height.
5151
bool get_block(system::chain::header::cptr& out,
52-
size_t height) const NOEXCEPT override;
52+
const header_link& link) const NOEXCEPT override;
5353

5454
/// Determine if Block is a duplicate (success for not duplicate).
5555
code duplicate(size_t& height,

include/bitcoin/node/chasers/chaser_organize.hpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class chaser_organize
5454
chain_state::cptr state;
5555
};
5656
using block_tree = std::unordered_map<system::hash_cref, block_state>;
57-
using header_links = std_vector<database::header_link>;
57+
using header_link = database::header_link;
5858

5959
/// Protected constructor for abstract base.
6060
chaser_organize(full_node& node) NOEXCEPT;
@@ -66,9 +66,9 @@ class chaser_organize
6666
virtual const system::chain::header& get_header(
6767
const Block& block) const NOEXCEPT = 0;
6868

69-
/// Query store for const pointer to Block instance by candidate height.
69+
/// Query store for const pointer to Block instance by link.
7070
virtual bool get_block(typename Block::cptr& out,
71-
size_t height) const NOEXCEPT = 0;
71+
const header_link& link) const NOEXCEPT = 0;
7272

7373
/// Determine if Block is a duplicate (success for not duplicate).
7474
virtual code duplicate(size_t& height,
@@ -112,6 +112,9 @@ class chaser_organize
112112
virtual const system::settings& settings() const NOEXCEPT;
113113

114114
private:
115+
using header_links = database::header_links;
116+
using header_states = database::header_states;
117+
115118
// Template differetiators.
116119
// ------------------------------------------------------------------------
117120

@@ -162,14 +165,10 @@ class chaser_organize
162165
const system::hash_digest& previous_hash) const NOEXCEPT;
163166

164167
// Sum of work from header to branch point (excluded).
165-
bool get_branch_work(uint256_t& branch_work, size_t& branch_point,
166-
system::hashes& tree_branch, header_links& store_branch,
168+
bool get_branch_work(uint256_t& branch_work,
169+
system::hashes& tree_branch, header_states& store_branch,
167170
const system::chain::header& header) const NOEXCEPT;
168171

169-
// True if work represents a stronger candidate branch.
170-
bool get_is_strong(bool& strong, const uint256_t& branch_work,
171-
size_t branch_point) const NOEXCEPT;
172-
173172
// Logging.
174173
// ------------------------------------------------------------------------
175174

0 commit comments

Comments
 (0)