Skip to content

Commit 9326b32

Browse files
authored
Merge pull request #700 from evoskuil/master
Add is_validateable().
2 parents bcf47fc + 585ad26 commit 9326b32

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/bitcoin/database/impl/query/validate.ipp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ namespace database {
2929
// States.
3030
// ----------------------------------------------------------------------------
3131

32+
TEMPLATE
33+
bool CLASS::is_validateable(size_t height) const NOEXCEPT
34+
{
35+
const auto ec = get_block_state(to_candidate(height));
36+
37+
// First block state should be unvalidated, valid, or confirmable.
38+
return
39+
(ec == database::error::unvalidated) ||
40+
(ec == database::error::block_valid) ||
41+
(ec == database::error::unknown_state) ||
42+
(ec == database::error::block_confirmable);
43+
}
44+
3245
// protected
3346
TEMPLATE
3447
inline code CLASS::to_block_code(

include/bitcoin/database/query.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ class query
457457
/// -----------------------------------------------------------------------
458458

459459
/// States.
460+
bool is_validateable(size_t height) const NOEXCEPT;
460461
uint64_t get_tx_fee(const tx_link& link) const NOEXCEPT;
461462
uint64_t get_block_fees(const header_link& link) const NOEXCEPT;
462463
code get_block_state(const header_link& link) const NOEXCEPT;

0 commit comments

Comments
 (0)