Skip to content

Commit

Permalink
Fix auto and local daemon connection mode
Browse files Browse the repository at this point in the history
  • Loading branch information
aivve committed Jan 17, 2021
1 parent 43ce14f commit 28f2530
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
10 changes: 6 additions & 4 deletions src/CryptoNoteWrapper/CryptoNoteAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,9 @@ void CryptoNoteAdapter::initNode() {
}

void CryptoNoteAdapter::initAutoConnection() {
WalletLogger::debug(tr("[CryptoNote wrapper] Searching local daemon: 127.0.0.1:%1").arg(CryptoNote::RPC_DEFAULT_PORT));
m_nodeAdapter = new ProxyRpcNodeAdapter(m_currency, m_coreLogger, m_walletLogger, QUrl::fromUserInput("http://127.0.0.1:" + CryptoNote::RPC_DEFAULT_PORT), this);
WalletLogger::info(tr("[CryptoNote wrapper] Searching local daemon: 127.0.0.1:%1").arg(CryptoNote::RPC_DEFAULT_PORT));
QString nodeUrl = "http://127.0.0.1:" + QString::number(CryptoNote::RPC_DEFAULT_PORT);
m_nodeAdapter = new ProxyRpcNodeAdapter(m_currency, m_coreLogger, m_walletLogger, QUrl::fromUserInput(nodeUrl), this);
m_nodeAdapter->addObserver(this);
m_autoConnectionTimerId = startTimer(AUTO_CONNECTION_INTERVAL);
m_nodeAdapter->init();
Expand All @@ -390,7 +391,8 @@ void CryptoNoteAdapter::initInProcessNode() {
}

void CryptoNoteAdapter::initLocalRpcNode() {
m_nodeAdapter = new ProxyRpcNodeAdapter(m_currency, m_coreLogger, m_walletLogger, QUrl::fromUserInput("http://127.0.0.1:" + m_localDaemodPort), this);
QString nodeUrl = "http://127.0.0.1:" + QString::number(m_localDaemodPort);
m_nodeAdapter = new ProxyRpcNodeAdapter(m_currency, m_coreLogger, m_walletLogger, QUrl::fromUserInput(nodeUrl), this);
m_nodeAdapter->addObserver(this);
m_nodeAdapter->init();
}
Expand All @@ -403,7 +405,7 @@ void CryptoNoteAdapter::initRemoteRpcNode() {
}

void CryptoNoteAdapter::onLocalDaemonNotFound() {
WalletLogger::debug(tr("[CryptoNote wrapper] Daemon on 127.0.0.1:%1 not found").arg(CryptoNote::RPC_DEFAULT_PORT));
WalletLogger::info(tr("[CryptoNote wrapper] Daemon on 127.0.0.1:%1 not found").arg(CryptoNote::RPC_DEFAULT_PORT));
killTimer(m_autoConnectionTimerId);
m_autoConnectionTimerId = -1;
QObject* nodeAdapter = dynamic_cast<QObject*>(m_nodeAdapter);
Expand Down
19 changes: 4 additions & 15 deletions src/CryptoNoteWrapper/ProxyRpcNodeWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,14 @@ void ProxyRpcNodeWorker::initImpl() {

QEventLoop waitLoop;
connect(this, &ProxyRpcNodeWorker::initCompletedSignal, &waitLoop, &QEventLoop::exit, Qt::QueuedConnection);
std::error_code initResult;

m_node.reset(new CryptoNote::NodeRpcProxy(m_nodeUrl.host().toStdString(), m_nodeUrl.port(), "/", m_nodeUrl.scheme().compare("https") == 0, m_loggerManager));
m_node->addObserver(static_cast<CryptoNote::INodeObserver*>(this));
m_node->addObserver(static_cast<CryptoNote::INodeRpcProxyObserver*>(this));
WalletLogger::debug(tr("[RPC node] NodeRpcProxy initializing..."));
m_node->init([this, &initResult](std::error_code _errorCode) {
Q_ASSERT(_errorCode.value() == 0);
initResult = _errorCode;
WalletLogger::info(tr("[RPC node] NodeRpcProxy initializing..."));
m_node->init([&](std::error_code _errorCode) {
if (_errorCode.value() == 0) {
if (m_blockchainExplorerAdapter == nullptr &&
Settings::instance().isBlockchainExplorerEnabled() && !m_node.isNull()/* &&
Settings::instance().getConnectionMethod() != ConnectionMethod::REMOTE*/) {
if (m_blockchainExplorerAdapter == nullptr && Settings::instance().isBlockchainExplorerEnabled() && !m_node.isNull()) {
WalletLogger::info(tr("[RPC node] Creating blockchain explorer..."));
BlockChainExplorerAdapter* blockchainExplorerAdapter = new BlockChainExplorerAdapter(*m_node, m_loggerManager, nullptr);
blockchainExplorerAdapter->moveToThread(qApp->thread());
Expand All @@ -196,15 +191,9 @@ void ProxyRpcNodeWorker::initImpl() {
} else {
WalletLogger::critical(tr("[RPC node] NodeRpcProxy init error: %1").arg(_errorCode.message().data()));
}
WalletLogger::debug(tr("[RPC node] NodeRpcProxy init result: %1").arg(_errorCode.value()));
WalletLogger::info(tr("[RPC node] NodeRpcProxy init result: %1").arg(_errorCode.value()));
});
WalletLogger::info(tr("[RPC node] Waiting..."));
waitLoop.exec();
if (initResult) {
WalletLogger::critical(tr("[RPC node] NodeRpcProxy init failed..."));
} else {

}
}

void ProxyRpcNodeWorker::deinitImpl() {
Expand Down

0 comments on commit 28f2530

Please sign in to comment.