Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/chain.cpp
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | class LockImpl : public Chain::Lock { | ||||
bool isPotentialTip(const BlockHash &hash) override { | bool isPotentialTip(const BlockHash &hash) override { | ||||
if (::ChainActive().Tip()->GetBlockHash() == hash) { | if (::ChainActive().Tip()->GetBlockHash() == hash) { | ||||
return true; | return true; | ||||
} | } | ||||
CBlockIndex *block = LookupBlockIndex(hash); | CBlockIndex *block = LookupBlockIndex(hash); | ||||
return block && block->GetAncestor(::ChainActive().Height()) == | return block && block->GetAncestor(::ChainActive().Height()) == | ||||
::ChainActive().Tip(); | ::ChainActive().Tip(); | ||||
} | } | ||||
CBlockLocator getLocator() override { | CBlockLocator getTipLocator() override { | ||||
return ::ChainActive().GetLocator(); | return ::ChainActive().GetLocator(); | ||||
} | } | ||||
Optional<int> findLocatorFork(const CBlockLocator &locator) override { | Optional<int> findLocatorFork(const CBlockLocator &locator) override { | ||||
LockAnnotation lock(::cs_main); | LockAnnotation lock(::cs_main); | ||||
if (CBlockIndex *fork = | if (CBlockIndex *fork = | ||||
FindForkInGlobalIndex(::ChainActive(), locator)) { | FindForkInGlobalIndex(::ChainActive(), locator)) { | ||||
return fork->nHeight; | return fork->nHeight; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 248 Lines • Show Last 20 Lines |