Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/chain.cpp
Show First 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height, | bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height, | ||||
const FoundBlock &block) override { | const FoundBlock &block) override { | ||||
WAIT_LOCK(cs_main, lock); | WAIT_LOCK(cs_main, lock); | ||||
return FillBlock( | return FillBlock( | ||||
ChainActive().FindEarliestAtLeast(min_time, min_height), block, | ChainActive().FindEarliestAtLeast(min_time, min_height), block, | ||||
lock); | lock); | ||||
} | } | ||||
bool findNextBlock(const BlockHash &block_hash, int block_height, | |||||
const FoundBlock &next, bool *reorg) override { | |||||
WAIT_LOCK(cs_main, lock); | |||||
CBlockIndex *block = ChainActive()[block_height]; | |||||
if (block && block->GetBlockHash() != block_hash) { | |||||
block = nullptr; | |||||
} | |||||
if (reorg) { | |||||
*reorg = !block; | |||||
} | |||||
return FillBlock(block ? ChainActive()[block_height + 1] : nullptr, | |||||
next, lock); | |||||
} | |||||
bool findAncestorByHeight(const BlockHash &block_hash, | bool findAncestorByHeight(const BlockHash &block_hash, | ||||
int ancestor_height, | int ancestor_height, | ||||
const FoundBlock &ancestor_out) override { | const FoundBlock &ancestor_out) override { | ||||
WAIT_LOCK(cs_main, lock); | WAIT_LOCK(cs_main, lock); | ||||
if (const CBlockIndex *block = LookupBlockIndex(block_hash)) { | if (const CBlockIndex *block = LookupBlockIndex(block_hash)) { | ||||
if (const CBlockIndex *ancestor = | if (const CBlockIndex *ancestor = | ||||
block->GetAncestor(ancestor_height)) { | block->GetAncestor(ancestor_height)) { | ||||
return FillBlock(ancestor, ancestor_out, lock); | return FillBlock(ancestor, ancestor_out, lock); | ||||
▲ Show 20 Lines • Show All 193 Lines • Show Last 20 Lines |