From fa3c6511435149782545ac0d09d4722dc115d709 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 19 Apr 2019 13:19:20 -0400 Subject: [refactor] interfaces: Add missing LockAnnotation for cs_main --- src/interfaces/chain.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/interfaces') diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp index fcbc442d12..59623284d2 100644 --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -41,6 +41,7 @@ class LockImpl : public Chain::Lock { Optional getHeight() override { + LockAnnotation lock(::cs_main); int height = ::ChainActive().Height(); if (height >= 0) { return height; @@ -49,6 +50,7 @@ class LockImpl : public Chain::Lock } Optional getBlockHeight(const uint256& hash) override { + LockAnnotation lock(::cs_main); CBlockIndex* block = LookupBlockIndex(hash); if (block && ::ChainActive().Contains(block)) { return block->nHeight; @@ -63,29 +65,34 @@ class LockImpl : public Chain::Lock } uint256 getBlockHash(int height) override { + LockAnnotation lock(::cs_main); CBlockIndex* block = ::ChainActive()[height]; assert(block != nullptr); return block->GetBlockHash(); } int64_t getBlockTime(int height) override { + LockAnnotation lock(::cs_main); CBlockIndex* block = ::ChainActive()[height]; assert(block != nullptr); return block->GetBlockTime(); } int64_t getBlockMedianTimePast(int height) override { + LockAnnotation lock(::cs_main); CBlockIndex* block = ::ChainActive()[height]; assert(block != nullptr); return block->GetMedianTimePast(); } bool haveBlockOnDisk(int height) override { + LockAnnotation lock(::cs_main); CBlockIndex* block = ::ChainActive()[height]; return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0; } Optional findFirstBlockWithTimeAndHeight(int64_t time, int height, uint256* hash) override { + LockAnnotation lock(::cs_main); CBlockIndex* block = ::ChainActive().FindEarliestAtLeast(time, height); if (block) { if (hash) *hash = block->GetBlockHash(); @@ -95,6 +102,7 @@ class LockImpl : public Chain::Lock } Optional findPruned(int start_height, Optional stop_height) override { + LockAnnotation lock(::cs_main); if (::fPruneMode) { CBlockIndex* block = stop_height ? ::ChainActive()[*stop_height] : ::ChainActive().Tip(); while (block && block->nHeight >= start_height) { @@ -108,6 +116,7 @@ class LockImpl : public Chain::Lock } Optional findFork(const uint256& hash, Optional* height) override { + LockAnnotation lock(::cs_main); const CBlockIndex* block = LookupBlockIndex(hash); const CBlockIndex* fork = block ? ::ChainActive().FindFork(block) : nullptr; if (height) { @@ -122,7 +131,11 @@ class LockImpl : public Chain::Lock } return nullopt; } - CBlockLocator getTipLocator() override { return ::ChainActive().GetLocator(); } + CBlockLocator getTipLocator() override + { + LockAnnotation lock(::cs_main); + return ::ChainActive().GetLocator(); + } Optional findLocatorFork(const CBlockLocator& locator) override { LockAnnotation lock(::cs_main); -- cgit v1.2.3