Bitcoin Core 32.99.0
P2P Digital Currency
block_validation_state_catcher.h
Go to the documentation of this file.
1// Copyright (c) 2021-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_NODE_BLOCK_VALIDATION_STATE_CATCHER_H
6#define BITCOIN_NODE_BLOCK_VALIDATION_STATE_CATCHER_H
7
10
11#include <memory>
12#include <optional>
13
14namespace node {
15
20{
21private:
23
24public:
25 std::optional<BlockValidationState> m_state;
26 explicit BlockValidationStateCatcher(const uint256& hash) : m_hash(hash) {};
27
28protected:
29 void BlockChecked(const std::shared_ptr<const CBlock>& block, const BlockValidationState& state) override
30 {
31 if (block->GetHash() == m_hash) m_state = state;
32 }
33};
34
35} // namespace node
36
37#endif // BITCOIN_NODE_BLOCK_VALIDATION_STATE_CATCHER_H
Implement this to subscribe to events generated in validation and mempool.
Captures the validation state reported for a specific block.
void BlockChecked(const std::shared_ptr< const CBlock > &block, const BlockValidationState &state) override
Notifies listeners of a block validation result.
std::optional< BlockValidationState > m_state
256-bit opaque blob.
Definition: uint256.h:196
Definition: messages.h:21