Skip to content

Commit

Permalink
Automatic Checkpointing update
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushstar committed Nov 30, 2018
1 parent 8f9c29d commit 6e9cff0
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 158 deletions.
32 changes: 0 additions & 32 deletions src/checkpoints.cpp
Expand Up @@ -28,36 +28,4 @@ namespace Checkpoints {
return nullptr;
}

int GetTotalBlocksEstimate(const CCheckpointData& data)
{
const MapCheckpoints& checkpoints = data.mapCheckpoints;

if (checkpoints.empty())
return 0;

return checkpoints.rbegin()->first;
}

uint256 GetLastAvailableCheckpoint(const CCheckpointData& data)
{
const MapCheckpoints& checkpoints = data.mapCheckpoints;

for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints))
{
const uint256& hash = i.second;
if (mapBlockIndex.count(hash) && chainActive.Contains(mapBlockIndex[hash]))
return hash;
}
return(Params().GetConsensus().hashGenesisBlock);
}

uint256 GetLatestHardenedCheckpoint(const CCheckpointData& data)
{
const MapCheckpoints& checkpoints = data.mapCheckpoints;

if (checkpoints.empty())
return Params().GetConsensus().hashGenesisBlock;

return (checkpoints.rbegin()->second);
}
} // namespace Checkpoints
9 changes: 0 additions & 9 deletions src/checkpoints.h
Expand Up @@ -22,15 +22,6 @@ namespace Checkpoints
//! Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
CBlockIndex* GetLastCheckpoint(const CCheckpointData& data);

//! Return conservative estimate of total number of blocks, 0 if unknown
int GetTotalBlocksEstimate(const CCheckpointData& data);

//! Returns the last available checkpoint in the main chain
uint256 GetLastAvailableCheckpoint(const CCheckpointData& data);

//! Returns the block hash of latest hardened checkpoint, if empty genesis block returned
uint256 GetLatestHardenedCheckpoint(const CCheckpointData& data);

} //namespace Checkpoints

#endif // BITCOIN_CHECKPOINTS_H

0 comments on commit 6e9cff0

Please sign in to comment.