forked from such-gitea/wownero
feat: add method for fetching both clockhain and target height
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
@@ -1424,6 +1425,9 @@ struct WalletManager
|
||||
//! returns current blockchain target height
|
||||
virtual uint64_t blockchainTargetHeight() = 0;
|
||||
|
||||
//! returns current blockchain and target height
|
||||
virtual std::pair<uint64_t, uint64_t> blockchainAndTargetHeight() = 0;
|
||||
|
||||
//! returns current network difficulty
|
||||
virtual uint64_t networkDifficulty() = 0;
|
||||
|
||||
|
||||
@@ -280,6 +280,18 @@ uint64_t WalletManagerImpl::blockchainTargetHeight()
|
||||
return ires.target_height >= ires.height ? ires.target_height : ires.height;
|
||||
}
|
||||
|
||||
std::pair<uint64_t, uint64_t> WalletManagerImpl::blockchainAndTargetHeight()
|
||||
{
|
||||
cryptonote::COMMAND_RPC_GET_INFO::request ireq;
|
||||
cryptonote::COMMAND_RPC_GET_INFO::response ires;
|
||||
|
||||
if (!epee::net_utils::invoke_http_json("/getinfo", ireq, ires, m_http_client))
|
||||
return std::make_pair(0, 0);
|
||||
uint64_t height = ires.height;
|
||||
uint64_t target_height = ires.target_height >= ires.height ? ires.target_height : ires.height;
|
||||
return std::make_pair(height, target_height);
|
||||
}
|
||||
|
||||
uint64_t WalletManagerImpl::networkDifficulty()
|
||||
{
|
||||
cryptonote::COMMAND_RPC_GET_INFO::request ireq;
|
||||
|
||||
@@ -95,6 +95,7 @@ public:
|
||||
bool connected(uint32_t *version = NULL) override;
|
||||
uint64_t blockchainHeight() override;
|
||||
uint64_t blockchainTargetHeight() override;
|
||||
std::pair<uint64_t, uint64_t> blockchainAndTargetHeight() override;
|
||||
uint64_t networkDifficulty() override;
|
||||
double miningHashRate() override;
|
||||
uint64_t blockTarget() override;
|
||||
|
||||
Reference in New Issue
Block a user