implement getIsConnected()

This commit is contained in:
woodser
2019-07-18 10:41:48 -04:00
parent 30c92decc2
commit 3b6e5e8eb0
2 changed files with 39 additions and 0 deletions
+29
View File
@@ -70,6 +70,10 @@ using namespace tools;
*/
namespace monero {
// ------------------------- INITIALIZE CONSTANTS ---------------------------
static const int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 1000 * 30;
// ----------------------- INTERNAL PRIVATE HELPERS -----------------------
bool boolEquals(bool val, const boost::optional<bool>& optVal) {
@@ -859,6 +863,31 @@ namespace monero {
return connection;
}
// TODO: could return Wallet::ConnectionStatus_Disconnected, Wallet::ConnectionStatus_WrongVersion, Wallet::ConnectionStatus_Connected like wallet.cpp::connected()
bool MoneroWallet::getIsConnected() {
uint32_t version = 0;
bool isConnected = wallet2->check_connection(&version, NULL, DEFAULT_CONNECTION_TIMEOUT_MILLIS);
if (!isConnected) return false;
if (!wallet2->light_wallet() && (version >> 16) != CORE_RPC_VERSION_MAJOR) return false;
return true;
}
long MoneroWallet::getDaemonHeight() {
throw runtime_error("getDaemonHeight() not implemented");
}
long MoneroWallet::getDaemonTargetHeight() {
throw runtime_error("getDaemonTargetHeight() not implemented");
}
bool MoneroWallet::getIsDaemonSynced() {
throw runtime_error("getIsDaemonSynced() not implemented");
}
bool MoneroWallet::getIsSynced() {
throw runtime_error("getIsSynced() not implemented");
}
string MoneroWallet::getPath() const {
return wallet2->path();
}
+10
View File
@@ -225,6 +225,16 @@ namespace monero {
*/
shared_ptr<MoneroRpcConnection> getDaemonConnection() const;
bool getIsConnected();
long getDaemonHeight();
long getDaemonTargetHeight();
bool getIsDaemonSynced();
bool getIsSynced();
/**
* TODO
*/