diff options
author | Antoine Riard <ariard@student.42.fr> | 2019-07-16 17:01:46 -0400 |
---|---|---|
committer | Antoine Riard <ariard@student.42.fr> | 2020-04-30 14:37:21 -0400 |
commit | 841178820d31e1c24a00cb2c8fc0b1fd2f126f56 (patch) | |
tree | b1d92f9637fe1259b5d8e31b7338b4f1d53d9379 /src/interfaces/chain.cpp | |
parent | 0a76287387950bc9c5b634e95c5cd5fb1029f42d (diff) | |
download | bitcoin-841178820d31e1c24a00cb2c8fc0b1fd2f126f56.tar.xz |
[wallet] Move methods from Chain::Lock interface to simple Chain
Remove findPruned and findFork, no more used after 17954.
Diffstat (limited to 'src/interfaces/chain.cpp')
-rw-r--r-- | src/interfaces/chain.cpp | 86 |
1 files changed, 34 insertions, 52 deletions
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp index a4702558dc..11cd20d785 100644 --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -55,58 +55,6 @@ bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<Rec class LockImpl : public Chain::Lock, public UniqueLock<RecursiveMutex> { - bool haveBlockOnDisk(int height) override - { - LockAssertion lock(::cs_main); - CBlockIndex* block = ::ChainActive()[height]; - return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0; - } - Optional<int> findFirstBlockWithTimeAndHeight(int64_t time, int height, uint256* hash) override - { - LockAssertion lock(::cs_main); - CBlockIndex* block = ::ChainActive().FindEarliestAtLeast(time, height); - if (block) { - if (hash) *hash = block->GetBlockHash(); - return block->nHeight; - } - return nullopt; - } - Optional<int> findFork(const uint256& hash, Optional<int>* height) override - { - LockAssertion lock(::cs_main); - const CBlockIndex* block = LookupBlockIndex(hash); - const CBlockIndex* fork = block ? ::ChainActive().FindFork(block) : nullptr; - if (height) { - if (block) { - *height = block->nHeight; - } else { - height->reset(); - } - } - if (fork) { - return fork->nHeight; - } - return nullopt; - } - CBlockLocator getTipLocator() override - { - LockAssertion lock(::cs_main); - return ::ChainActive().GetLocator(); - } - Optional<int> findLocatorFork(const CBlockLocator& locator) override - { - LockAssertion lock(::cs_main); - if (CBlockIndex* fork = FindForkInGlobalIndex(::ChainActive(), locator)) { - return fork->nHeight; - } - return nullopt; - } - bool checkFinalTx(const CTransaction& tx) override - { - LockAssertion lock(::cs_main); - return CheckFinalTx(tx); - } - using UniqueLock::UniqueLock; }; @@ -234,6 +182,40 @@ public: assert(block); return block->GetBlockHash(); } + bool haveBlockOnDisk(int height) override + { + LOCK(cs_main); + CBlockIndex* block = ::ChainActive()[height]; + return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0; + } + Optional<int> findFirstBlockWithTimeAndHeight(int64_t time, int height, uint256* hash) override + { + LOCK(cs_main); + CBlockIndex* block = ::ChainActive().FindEarliestAtLeast(time, height); + if (block) { + if (hash) *hash = block->GetBlockHash(); + return block->nHeight; + } + return nullopt; + } + CBlockLocator getTipLocator() override + { + LOCK(cs_main); + return ::ChainActive().GetLocator(); + } + bool checkFinalTx(const CTransaction& tx) override + { + LOCK(cs_main); + return CheckFinalTx(tx); + } + Optional<int> findLocatorFork(const CBlockLocator& locator) override + { + LOCK(cs_main); + if (CBlockIndex* fork = FindForkInGlobalIndex(::ChainActive(), locator)) { + return fork->nHeight; + } + return nullopt; + } bool findBlock(const uint256& hash, const FoundBlock& block) override { WAIT_LOCK(cs_main, lock); |