Initial implementation of getrescaninfo
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
// Copyright (c) 2016-2022 The Hush developers
|
||||
// Distributed under the GPLv3 software license, see the accompanying
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -17,7 +16,6 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "chain.h"
|
||||
#include "key_io.h"
|
||||
#include "rpc/server.h"
|
||||
@@ -29,13 +27,10 @@
|
||||
#include "util.h"
|
||||
#include "utiltime.h"
|
||||
#include "wallet.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
using namespace std;
|
||||
@@ -149,6 +144,39 @@ UniValue convertpassphrase(const UniValue& params, bool fHelp, const CPubKey& my
|
||||
return ret;
|
||||
}
|
||||
|
||||
UniValue getrescaninfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
if (fHelp || params.size() > 0)
|
||||
throw runtime_error(
|
||||
"getrescaninfo\n"
|
||||
"\nGet rescan info such as starting height and current height.\n"
|
||||
"\nArguments: none\n"
|
||||
"\nExamples:\n"
|
||||
"\nGet rescan info:\n"
|
||||
+ HelpExampleCli("getrescaninfo","")
|
||||
);
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
auto rescanning = pwalletMain->fRescanning;
|
||||
ret.push_back(Pair("rescanning", rescanning));
|
||||
if(rescanning) {
|
||||
auto rescanHeight = pwalletMain->rescanHeight;
|
||||
auto startHeight = pwalletMain->rescanStartHeight;
|
||||
auto currentHeight = chainActive.Height();
|
||||
// if current height is 0, progress=1 since there is nothing to rescan
|
||||
char progress[8];
|
||||
if (currentHeight != 0) {
|
||||
sprintf(progress, "%.4f", (double) rescanHeight / (double) currentHeight );
|
||||
ret.push_back(Pair("rescan_progress", progress));
|
||||
}
|
||||
ret.push_back(Pair("rescan_start_height", startHeight));
|
||||
ret.push_back(Pair("rescan_height", rescanHeight));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
UniValue rescan(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
//LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
Reference in New Issue
Block a user