Skip to content
This repository has been archived by the owner on Nov 28, 2019. It is now read-only.

Commit

Permalink
Implement simple initialblockdownload estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed Nov 26, 2018
1 parent d776b39 commit 1546538
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,20 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
obj.push_back(Pair("signblock_asm", ScriptToAsmStr(tip->proof.challenge)));
obj.push_back(Pair("signblock_hex", HexStr(tip->proof.challenge.begin(), tip->proof.challenge.end())));

// Since we have signed fixed-interval blocks, we can estimate initialblockdownload based
// on the time since the last block.
bool initialblockdownload = true;
if (tip->nHeight > 2) {
int64_t nNow = time(NULL);
int64_t sinceLast = nNow - tip->GetBlockTime();

// We assume we're done if the last blocks is less than 5 intervals ago.
if (sinceLast < 5 * Params().GetConsensus().nPowTargetSpacing) {
initialblockdownload = false;
}
}
obj.push_back(Pair("initialblockdownload", initialblockdownload));

const Consensus::Params& consensusParams = Params().GetConsensus();
UniValue bip9_softforks(UniValue::VOBJ);
BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV);
Expand Down

0 comments on commit 1546538

Please sign in to comment.