mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Implement "getchaintips" RPC command to monitor blockchain forks.
Port over https://github.com/chronokings/huntercoin/pull/19 from Huntercoin: This implements a new RPC command "getchaintips" that can be used to find all currently active chain heads. This is similar to the -printblocktree startup option, but it can be used without restarting just via the RPC interface on a running daemon.
This commit is contained in:
@@ -444,7 +444,7 @@ CBlockIndex *CChain::FindFork(const CBlockLocator &locator) const {
|
||||
return Genesis();
|
||||
}
|
||||
|
||||
CBlockIndex *CChain::FindFork(CBlockIndex *pindex) const {
|
||||
const CBlockIndex *CChain::FindFork(const CBlockIndex *pindex) const {
|
||||
if (pindex->nHeight > Height())
|
||||
pindex = pindex->GetAncestor(Height());
|
||||
while (pindex && !Contains(pindex))
|
||||
@@ -2067,8 +2067,8 @@ static CBlockIndex* FindMostWorkChain() {
|
||||
static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork) {
|
||||
AssertLockHeld(cs_main);
|
||||
bool fInvalidFound = false;
|
||||
CBlockIndex *pindexOldTip = chainActive.Tip();
|
||||
CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork);
|
||||
const CBlockIndex *pindexOldTip = chainActive.Tip();
|
||||
const CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork);
|
||||
|
||||
// Disconnect active blocks which are no longer in the best chain.
|
||||
while (chainActive.Tip() && chainActive.Tip() != pindexFork) {
|
||||
|
||||
Reference in New Issue
Block a user