diff options
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/chain.cpp | 8 | ||||
-rw-r--r-- | src/interfaces/chain.h | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp index cfaf79f709..1c1fbe7387 100644 --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -267,6 +267,14 @@ public: WAIT_LOCK(cs_main, lock); return FillBlock(LookupBlockIndex(hash), block, lock); } + bool findAncestorByHash(const uint256& block_hash, const uint256& ancestor_hash, const FoundBlock& ancestor_out) override + { + WAIT_LOCK(cs_main, lock); + const CBlockIndex* block = LookupBlockIndex(block_hash); + const CBlockIndex* ancestor = LookupBlockIndex(ancestor_hash); + if (block && ancestor && block->GetAncestor(ancestor->nHeight) != ancestor) ancestor = nullptr; + return FillBlock(ancestor, ancestor_out, lock); + } void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(m_node, coins); } double guessVerificationProgress(const uint256& block_hash) override { diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 3778ab9a8b..7504f4cfb6 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -150,6 +150,12 @@ public: //! or contents. virtual bool findBlock(const uint256& hash, const FoundBlock& block={}) = 0; + //! Return whether block descends from a specified ancestor, and + //! optionally return ancestor information. + virtual bool findAncestorByHash(const uint256& block_hash, + const uint256& ancestor_hash, + const FoundBlock& ancestor_out={}) = 0; + //! Look up unspent output information. Returns coins in the mempool and in //! the current chain UTXO set. Iterates through all the keys in the map and //! populates the values. |