|
|
|
@ -41,7 +41,7 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
|
|
|
|
|
{
|
|
|
|
|
Optional<int> getHeight() override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
int height = ::ChainActive().Height();
|
|
|
|
|
if (height >= 0) {
|
|
|
|
|
return height;
|
|
|
|
@ -50,7 +50,7 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
|
|
|
|
|
}
|
|
|
|
|
Optional<int> getBlockHeight(const uint256& hash) override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
CBlockIndex* block = LookupBlockIndex(hash);
|
|
|
|
|
if (block && ::ChainActive().Contains(block)) {
|
|
|
|
|
return block->nHeight;
|
|
|
|
@ -65,34 +65,34 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
|
|
|
|
|
}
|
|
|
|
|
uint256 getBlockHash(int height) override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
CBlockIndex* block = ::ChainActive()[height];
|
|
|
|
|
assert(block != nullptr);
|
|
|
|
|
return block->GetBlockHash();
|
|
|
|
|
}
|
|
|
|
|
int64_t getBlockTime(int height) override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
CBlockIndex* block = ::ChainActive()[height];
|
|
|
|
|
assert(block != nullptr);
|
|
|
|
|
return block->GetBlockTime();
|
|
|
|
|
}
|
|
|
|
|
int64_t getBlockMedianTimePast(int height) override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
CBlockIndex* block = ::ChainActive()[height];
|
|
|
|
|
assert(block != nullptr);
|
|
|
|
|
return block->GetMedianTimePast();
|
|
|
|
|
}
|
|
|
|
|
bool haveBlockOnDisk(int height) override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
CBlockIndex* block = ::ChainActive().FindEarliestAtLeast(time, height);
|
|
|
|
|
if (block) {
|
|
|
|
|
if (hash) *hash = block->GetBlockHash();
|
|
|
|
@ -102,7 +102,7 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
|
|
|
|
|
}
|
|
|
|
|
Optional<int> findPruned(int start_height, Optional<int> stop_height) override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
if (::fPruneMode) {
|
|
|
|
|
CBlockIndex* block = stop_height ? ::ChainActive()[*stop_height] : ::ChainActive().Tip();
|
|
|
|
|
while (block && block->nHeight >= start_height) {
|
|
|
|
@ -116,7 +116,7 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
|
|
|
|
|
}
|
|
|
|
|
Optional<int> findFork(const uint256& hash, Optional<int>* height) override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
const CBlockIndex* block = LookupBlockIndex(hash);
|
|
|
|
|
const CBlockIndex* fork = block ? ::ChainActive().FindFork(block) : nullptr;
|
|
|
|
|
if (height) {
|
|
|
|
@ -133,12 +133,12 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
|
|
|
|
|
}
|
|
|
|
|
CBlockLocator getTipLocator() override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
return ::ChainActive().GetLocator();
|
|
|
|
|
}
|
|
|
|
|
Optional<int> findLocatorFork(const CBlockLocator& locator) override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
if (CBlockIndex* fork = FindForkInGlobalIndex(::ChainActive(), locator)) {
|
|
|
|
|
return fork->nHeight;
|
|
|
|
|
}
|
|
|
|
@ -146,12 +146,12 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
|
|
|
|
|
}
|
|
|
|
|
bool checkFinalTx(const CTransaction& tx) override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
return CheckFinalTx(tx);
|
|
|
|
|
}
|
|
|
|
|
bool submitToMemoryPool(const CTransactionRef& tx, CAmount absurd_fee, CValidationState& state) override
|
|
|
|
|
{
|
|
|
|
|
LockAnnotation lock(::cs_main);
|
|
|
|
|
LockAssertion lock(::cs_main);
|
|
|
|
|
return AcceptToMemoryPool(::mempool, state, tx, nullptr /* missing inputs */, nullptr /* txn replaced */,
|
|
|
|
|
false /* bypass limits */, absurd_fee);
|
|
|
|
|
}
|
|
|
|
|