diff options
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/chain.cpp | 14 | ||||
-rw-r--r-- | src/interfaces/chain.h | 6 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp index ccdbf1f1d1..a4702558dc 100644 --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -55,13 +55,6 @@ bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<Rec class LockImpl : public Chain::Lock, public UniqueLock<RecursiveMutex> { - uint256 getBlockHash(int height) override - { - LockAssertion lock(::cs_main); - CBlockIndex* block = ::ChainActive()[height]; - assert(block != nullptr); - return block->GetBlockHash(); - } bool haveBlockOnDisk(int height) override { LockAssertion lock(::cs_main); @@ -234,6 +227,13 @@ public: } return nullopt; } + uint256 getBlockHash(int height) override + { + LOCK(::cs_main); + CBlockIndex* block = ::ChainActive()[height]; + assert(block); + return block->GetBlockHash(); + } bool findBlock(const uint256& hash, const FoundBlock& block) override { WAIT_LOCK(cs_main, lock); diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index b85484c11b..c82ade8897 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -87,9 +87,6 @@ public: public: virtual ~Lock() {} - //! Get block hash. Height must be valid or this function will abort. - virtual uint256 getBlockHash(int height) = 0; - //! Check that the block is available on disk (i.e. has not been //! pruned), and contains transactions. virtual bool haveBlockOnDisk(int height) = 0; @@ -135,6 +132,9 @@ public: //! included in the current chain. virtual Optional<int> getBlockHeight(const uint256& hash) = 0; + //! Get block hash. Height must be valid or this function will abort. + virtual uint256 getBlockHash(int height) = 0; + //! Return whether node has the block and optionally return block metadata //! or contents. virtual bool findBlock(const uint256& hash, const FoundBlock& block={}) = 0; |