aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/chain.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-04-19 13:19:20 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-05-13 14:46:01 -0400
commitfa3c6511435149782545ac0d09d4722dc115d709 (patch)
tree4b50c659cd37aa21590050479c8e525ad017d9e1 /src/interfaces/chain.cpp
parent14959753a424f04be118630f691ecab9b0df7e9e (diff)
[refactor] interfaces: Add missing LockAnnotation for cs_main
Diffstat (limited to 'src/interfaces/chain.cpp')
-rw-r--r--src/interfaces/chain.cpp15
1 files changed, 14 insertions, 1 deletions
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<int> 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<int> 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<int> 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<int> findPruned(int start_height, Optional<int> 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<int> findFork(const uint256& hash, Optional<int>* 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<int> findLocatorFork(const CBlockLocator& locator) override
{
LockAnnotation lock(::cs_main);