From 5c6ec309b15f251ef4f382e871ca49b52016d866 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 12 Nov 2014 16:05:07 -0800 Subject: [PATCH] cleanup progress. --- src/bitcoindjs.cc | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 9e8f16de..32acbb9f 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -1839,24 +1839,17 @@ async_get_progress_after(uv_work_t *req) { Local genesis = NanNew(); cblock_to_jsblock(cgenesis, NULL, genesis, false); - // int64_t ts_ = cblock.GetBlockTime(); - time_t now_ = time(NULL); + // Get progress: + double progress = Checkpoints::GuessVerificationProgress(cblock_index, false); - //int64_t now = (int64_t)(time(NULL) - (10 * 60)); - // int64_t ts = (int64_t)ts_; - - // Assume last block was ten minutes ago: - int64_t now = ((int64_t)now_ - (10 * 60)); - - // int64_t left = (now - ts); // get left from timestamp - // double cur = (double)(now - left) / (double)now; - - double cur = Checkpoints::GuessVerificationProgress(cblock_index, false); - int64_t left = now - (cur * now); // get left from guess checkpoints + // Get time left (assume last block was ten minutes ago): + int64_t now = ((int64_t)time(NULL) - (10 * 60)); + int64_t left = now - (progress * now); + // Calculate tangible progress: unsigned int hours_behind = left / 60 / 60; unsigned int days_behind = left / 60 / 60 / 24; - unsigned int percent = (unsigned int)(cur * 100.0); + unsigned int percent = (unsigned int)(progress * 100.0); Local result = NanNew(); @@ -1869,11 +1862,6 @@ async_get_progress_after(uv_work_t *req) { result->Set(NanNew("hoursBehind"), NanNew(hours_behind)); result->Set(NanNew("daysBehind"), NanNew(days_behind)); result->Set(NanNew("percent"), NanNew(percent)); - - // unsigned long orphan_count = (unsigned long)mapOrphanBlocks.size(); - // result->Set(NanNew("orphans"), NanNew(orphan_count)); - // result->Set(NanNew("orphans"), NanNew( - // (unsigned long)mapOrphanBlocks.size())->ToInteger()); // result->Set(NanNew("orphans"), // NanNew(mapOrphanBlocks.size()));