GetProgress

- uses the same routine as the log reporter in bitcoin
- essentially divides the chainParams checkpoints by the current tip
This commit is contained in:
Chris Kleeschulte 2015-08-11 12:31:54 -04:00
parent 1027a77d6f
commit f2c6d310ae
2 changed files with 14 additions and 0 deletions

View File

@ -216,6 +216,18 @@ NAN_METHOD(VerifyScript) {
static bool
set_cooked(void);
/**
* GetProgress()
* bitcoind.getProgress()
* provides a float value >= indicating the progress of the blockchain sync
*/
NAN_METHOD(GetProgress) {
const CChainParams& chainParams = Params();
float progress = 0;
progress = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip());
NanReturnValue(progress);
};
NAN_METHOD(StartTxMon) {
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
@ -1670,6 +1682,7 @@ init(Handle<Object> target) {
NODE_SET_METHOD(target, "sendTransaction", SendTransaction);
NODE_SET_METHOD(target, "estimateFee", EstimateFee);
NODE_SET_METHOD(target, "startTxMon", StartTxMon);
NODE_SET_METHOD(target, "getProgress", GetProgress);
}

View File

@ -31,3 +31,4 @@ NAN_METHOD(VerifyScript);
NAN_METHOD(SendTransaction);
NAN_METHOD(EstimateFee);
NAN_METHOD(StartTxMon);
NAN_METHOD(GetProgress);