diff --git a/chain/wallet/handlers/DapGetAllWalletHistoryCommand.cpp b/chain/wallet/handlers/DapGetAllWalletHistoryCommand.cpp index a6ec467a83213a337f389c26351bec95d5078ab5..e084f5a1116026f766d5e002b4d0801f6cff01fb 100644 --- a/chain/wallet/handlers/DapGetAllWalletHistoryCommand.cpp +++ b/chain/wallet/handlers/DapGetAllWalletHistoryCommand.cpp @@ -52,7 +52,7 @@ QVariant DapGetAllWalletHistoryCommand::respondToClient(const QVariant &arg1, co process.start(command); process.waitForFinished(-1); QByteArray result = process.readAll(); - qInfo() << "result:" << result; +// qInfo() << "result:" << result; if(!result.isEmpty()) { @@ -100,11 +100,11 @@ QVariant DapGetAllWalletHistoryCommand::respondToClient(const QVariant &arg1, co // event.setAmountWithoutZeros(amountWithoutZeros); - qDebug() << "DapWalletHistoryEvent" << match.captured(1) - << event.getWallet() - << event.getName() << event.getNetwork() -// << event.getAmountWithoutZeros() << event.getDatoshi() << event.getStatus() - << event.getDate() << event.getSecsSinceEpoch(); +// qDebug() << "DapWalletHistoryEvent" << match.captured(1) +// << event.getWallet() +// << event.getName() << event.getNetwork() +//// << event.getAmountWithoutZeros() << event.getDatoshi() << event.getStatus() +// << event.getDate() << event.getSecsSinceEpoch(); events.append(event); } diff --git a/chain/wallet/handlers/DapGetListTokensCommand.cpp b/chain/wallet/handlers/DapGetListTokensCommand.cpp index 699bf3bd10ddaf6df0468cbb2cdf691020aca6e4..a01774cf2c3e3ba2e307027db01138f85b48097b 100644 --- a/chain/wallet/handlers/DapGetListTokensCommand.cpp +++ b/chain/wallet/handlers/DapGetListTokensCommand.cpp @@ -33,8 +33,6 @@ QVariant DapGetListTokensCommand::respondToClient(const QVariant &arg1, const QV qDebug() << "DapGetListTokensCommand::respondToClient"; - - QJsonArray array; QStringList netlist; @@ -55,6 +53,10 @@ QVariant DapGetListTokensCommand::respondToClient(const QVariant &arg1, const QV if(!(result.isEmpty() || result.isNull() || result.contains('\''))) netlist = result.split('\n', QString::SkipEmptyParts); + QString tempResult; + + bool update = arg1.toString() == "update"; + for (QString net : netlist) { QJsonObject obj; @@ -62,13 +64,15 @@ QVariant DapGetListTokensCommand::respondToClient(const QVariant &arg1, const QV qDebug()<<net; QJsonArray arrTokens; - QString command = QString("%1 ledger list coins -net %2").arg(m_sCliPath).arg(net); + command = QString("%1 ledger list coins -net %2").arg(m_sCliPath).arg(net); QProcess process; qDebug() << "command:" << command; process.start(command); process.waitForFinished(-1); - QString result = QString::fromLatin1(process.readAll()); + result = QString::fromLatin1(process.readAll()); + + tempResult.append(result); // qDebug() << "result:" << result; // (')([^']+) @@ -112,10 +116,28 @@ QVariant DapGetListTokensCommand::respondToClient(const QVariant &arg1, const QV array.append(obj); } - QJsonDocument docResult; - docResult.setArray(array); - return docResult.toJson(); + if (tempResult != lastResult || !update) + { + lastResult = tempResult; + + qDebug() << "lastResult" << lastResult; + + QJsonDocument docResult; + docResult.setArray(array); + + return docResult.toJson(); + } + else + { + qDebug() << "isEqual"; + + return QVariant(QString("isEqual")); + } +// QJsonDocument docResult; +// docResult.setArray(array); + +// return docResult.toJson(); } QString DapGetListTokensCommand::deleteZeros(QString balance) diff --git a/chain/wallet/handlers/DapGetListTokensCommand.h b/chain/wallet/handlers/DapGetListTokensCommand.h index 68269b5e9abb89c04dfb784f5d8766e338d79905..e98f72d9f2b8b5e98d278769dab06a198e55fc04 100644 --- a/chain/wallet/handlers/DapGetListTokensCommand.h +++ b/chain/wallet/handlers/DapGetListTokensCommand.h @@ -37,6 +37,9 @@ public slots: const QVariant &arg9 = QVariant(), const QVariant &arg10 = QVariant()) override; QString deleteZeros(QString); + +private: + QString lastResult; }; #endif // DAPGETLISTTOKENSCOMMAND_H diff --git a/chain/wallet/handlers/DapGetWalletHistoryCommand.cpp b/chain/wallet/handlers/DapGetWalletHistoryCommand.cpp index 411a2e3b08b3abd66ab77ae60303cbba95817aa7..58e18d775e874ee035181b87533ea1edba276b1d 100644 --- a/chain/wallet/handlers/DapGetWalletHistoryCommand.cpp +++ b/chain/wallet/handlers/DapGetWalletHistoryCommand.cpp @@ -40,7 +40,7 @@ QVariant DapGetWalletHistoryCommand::respondToClient(const QVariant &arg1, const process.start(command); process.waitForFinished(-1); QByteArray result = process.readAll(); - qInfo() << "result:" << result; +// qInfo() << "result:" << result; result.replace("\t", ""); if(!result.isEmpty()) { @@ -87,10 +87,10 @@ QVariant DapGetWalletHistoryCommand::respondToClient(const QVariant &arg1, const event.setAmountWithoutZeros(amountWithoutZeros); - qDebug() << "DapWalletHistoryEvent" << match.captured(1) - << event.getName() << event.getNetwork() - << event.getAmountWithoutZeros() << event.getDatoshi() << event.getStatus() - << event.getDate() << event.getSecsSinceEpoch(); +// qDebug() << "DapWalletHistoryEvent" << match.captured(1) +// << event.getName() << event.getNetwork() +// << event.getAmountWithoutZeros() << event.getDatoshi() << event.getStatus() +// << event.getDate() << event.getSecsSinceEpoch(); events.append(event); } diff --git a/chain/wallet/handlers/DapGetXchangeTokenPair.cpp b/chain/wallet/handlers/DapGetXchangeTokenPair.cpp index 8ff2838e211af5c7cbf451477239b6b6b2860784..ba6d581e6a0d9b10be700b42b76bf576edcb5163 100644 --- a/chain/wallet/handlers/DapGetXchangeTokenPair.cpp +++ b/chain/wallet/handlers/DapGetXchangeTokenPair.cpp @@ -30,33 +30,40 @@ QVariant DapGetXchangeTokenPair::respondToClient(const QVariant &arg1, const QVa QJsonArray arrPairs; - QStringList netlist; +// QStringList netlist; QProcess process; - QString command = QString("%1 net list").arg(m_sCliPath); + QString command; + QString result; + command = QString("%1 net list").arg(m_sCliPath); qDebug() << "command:" << command; process.start(command); process.waitForFinished(-1); - QString result = QString::fromLatin1(process.readAll()); -// qDebug() << "result:" << result; + result = QString::fromLatin1(process.readAll()); + qDebug() << "result:" << result; result.remove(' '); result.remove('\r'); result.remove('\t'); result.remove("Networks:"); + QStringList netlist; if(!(result.isEmpty() || result.isNull() || result.contains('\''))) netlist = result.split('\n', QString::SkipEmptyParts); + QString tempResult; + QString fullInfo = arg1.toString(); + + bool update = false; + if (arg1.toString() == "update" || arg2.toString() == "update") + update = true; + for (QString net : netlist) { //TODO:: only subzero for debud. Node crash // if(net == "subzero") { - - QString fullInfo = arg1.toString(); - - QString command = QString("%1 srv_xchange token_pair -net %2 list all") + command = QString("%1 srv_xchange token_pair -net %2 list all") .arg(m_sCliPath).arg(net); QProcess process; @@ -64,7 +71,9 @@ QVariant DapGetXchangeTokenPair::respondToClient(const QVariant &arg1, const QVa qDebug() << "command:" << command; process.start(command); process.waitForFinished(-1); - QString result = QString::fromLatin1(process.readAll()); + result = QString::fromLatin1(process.readAll()); + + tempResult.append(result); // qDebug() << "result:" << result; @@ -97,6 +106,7 @@ QVariant DapGetXchangeTokenPair::respondToClient(const QVariant &arg1, const QVa process.waitForFinished(-1); result = QString::fromLatin1(process.readAll()); + tempResult.append(result); // qDebug() << "result:" << result; @@ -119,8 +129,24 @@ QVariant DapGetXchangeTokenPair::respondToClient(const QVariant &arg1, const QVa } } - QJsonDocument docResult; - docResult.setArray(arrPairs); +// qDebug() << "tempResult" << tempResult +// << "lastResult" << lastResult; - return docResult.toJson(); + if (tempResult != lastResult || !update) + { + lastResult = tempResult; + + qDebug() << "lastResult" << lastResult; + + QJsonDocument docResult; + docResult.setArray(arrPairs); + + return docResult.toJson(); + } + else + { + qDebug() << "isEqual"; + + return QVariant(QString("isEqual")); + } } diff --git a/chain/wallet/handlers/DapGetXchangeTokenPair.h b/chain/wallet/handlers/DapGetXchangeTokenPair.h index 935f36b5f6a857be7d6a7fb08961bc86f6b80e86..95f9f7ccbb13f8300624f69104833348bf469221 100644 --- a/chain/wallet/handlers/DapGetXchangeTokenPair.h +++ b/chain/wallet/handlers/DapGetXchangeTokenPair.h @@ -26,6 +26,9 @@ public slots: const QVariant &arg5 = QVariant(), const QVariant &arg6 = QVariant(), const QVariant &arg7 = QVariant(), const QVariant &arg8 = QVariant(), const QVariant &arg9 = QVariant(), const QVariant &arg10 = QVariant()) override; + +private: + QString lastResult; }; #endif // DAPGETXCHANGETOKENPAIR_H diff --git a/chain/wallet/handlers/DapVersionController.cpp b/chain/wallet/handlers/DapVersionController.cpp index 8dfb5fab4cb689ec3e53eb0a0367a9e38294bd01..e08193b752de6bf7b05998e21467ad429a42ecca 100644 --- a/chain/wallet/handlers/DapVersionController.cpp +++ b/chain/wallet/handlers/DapVersionController.cpp @@ -93,6 +93,24 @@ QVariant DapVersionController::respondToClient(const QVariant &arg1, const QVari // resultObj.insert(MESSAGE,QJsonValue("The update process has started.")); // return installPack() ? resultObj:resultObj; } + else if(arg1.toString() == "version node") + { + QProcess process; + QString command = QString("%1 version").arg(CLI_PATH); + process.start(command); + process.waitForFinished(-1); + QString result = QString::fromLatin1(process.readAll()); + + if(result.contains("cellframe-node version")) + { + result = result.split("version")[1]; + result = result.split('\n', QString::SkipEmptyParts).first().trimmed(); + resultObj.insert(LAST_VERSION,QJsonValue(result)); + resultObj.insert(MESSAGE,QJsonValue("Reply node version")); + } + else + resultObj.insert(MESSAGE,QJsonValue("Error. " + result)); + } return resultObj; }