Helper for findBlock to selectively return pieces of block data. If block is found, data will be returned by setting specified output variables. If block is not found, output variables will keep their previous values.
| 43 | //! found, data will be returned by setting specified output variables. If block |
| 44 | //! is not found, output variables will keep their previous values. |
| 45 | class FoundBlock |
| 46 | { |
| 47 | public: |
| 48 | FoundBlock& hash(uint256& hash) { m_hash = &hash; return *this; } |
| 49 | FoundBlock& height(int& height) { m_height = &height; return *this; } |
| 50 | FoundBlock& time(int64_t& time) { m_time = &time; return *this; } |
| 51 | FoundBlock& maxTime(int64_t& max_time) { m_max_time = &max_time; return *this; } |
| 52 | FoundBlock& mtpTime(int64_t& mtp_time) { m_mtp_time = &mtp_time; return *this; } |
| 53 | //! Return whether block is in the active (most-work) chain. |
| 54 | FoundBlock& inActiveChain(bool& in_active_chain) { m_in_active_chain = &in_active_chain; return *this; } |
| 55 | //! Return next block in the active chain if current block is in the active chain. |
| 56 | FoundBlock& nextBlock(const FoundBlock& next_block) { m_next_block = &next_block; return *this; } |
| 57 | //! Read block data from disk. If the block exists but doesn't have data |
| 58 | //! (for example due to pruning), the CBlock variable will be set to null. |
| 59 | FoundBlock& data(CBlock& data) { m_data = &data; return *this; } |
| 60 | |
| 61 | uint256* m_hash = nullptr; |
| 62 | int* m_height = nullptr; |
| 63 | int64_t* m_time = nullptr; |
| 64 | int64_t* m_max_time = nullptr; |
| 65 | int64_t* m_mtp_time = nullptr; |
| 66 | bool* m_in_active_chain = nullptr; |
| 67 | const FoundBlock* m_next_block = nullptr; |
| 68 | CBlock* m_data = nullptr; |
| 69 | mutable bool found = false; |
| 70 | }; |
| 71 | |
| 72 | //! Interface giving clients (wallet processes, maybe other analysis tools in |
| 73 | //! the future) ability to access to the chain state, receive notifications, |
no outgoing calls