From 78ea0fa766eea177e7df9cefab4a20381606b4f0 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 6 Nov 2014 15:40:32 +0100 Subject: [PATCH] missing changes --- libjsqrc/main.js | 4 ++-- libqethereum/QEthereum.cpp | 29 +++++++++++++++++------------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/libjsqrc/main.js b/libjsqrc/main.js index ed535c7fa..c1da61cd2 100644 --- a/libjsqrc/main.js +++ b/libjsqrc/main.js @@ -293,11 +293,11 @@ setupMethods(web3.shh, shhMethods()); var ethWatch = { - changed: 'changed' + changed: 'eth_changed' }; setupMethods(ethWatch, ethWatchMethods()); var shhWatch = { - changed: 'shhChanged' + changed: 'shh_changed' }; setupMethods(shhWatch, shhWatchMethods()); diff --git a/libqethereum/QEthereum.cpp b/libqethereum/QEthereum.cpp index 08165d9db..2c3b96538 100644 --- a/libqethereum/QEthereum.cpp +++ b/libqethereum/QEthereum.cpp @@ -59,13 +59,13 @@ void QWebThree::poll() { if (m_watches.size() > 0) { - QString batch = toJsonRpcBatch(m_watches, "changed"); - emit processData(batch, "changed"); + QString batch = toJsonRpcBatch(m_watches, "eth_changed"); + emit processData(batch, "eth_changed"); } if (m_shhWatches.size() > 0) { - QString batch = toJsonRpcBatch(m_shhWatches, "shhChanged"); - emit processData(batch, "shhChanged"); + QString batch = toJsonRpcBatch(m_shhWatches, "shh_changed"); + emit processData(batch, "shh_changed"); } } @@ -73,13 +73,13 @@ void QWebThree::clearWatches() { if (m_watches.size() > 0) { - QString batch = toJsonRpcBatch(m_watches, "uninstallFilter"); + QString batch = toJsonRpcBatch(m_watches, "eth_uninstallFilter"); m_watches.clear(); emit processData(batch, "internal"); } if (m_shhWatches.size() > 0) { - QString batch = toJsonRpcBatch(m_shhWatches, "shhUninstallFilter"); + QString batch = toJsonRpcBatch(m_shhWatches, "shh_uninstallFilter"); m_shhWatches.clear(); emit processData(batch, "internal"); } @@ -106,7 +106,12 @@ void QWebThree::postMessage(QString _json) QJsonObject f = QJsonDocument::fromJson(_json.toUtf8()).object(); QString method = f["call"].toString(); - if (!method.compare("uninstallFilter") && f["args"].isArray() && f["args"].toArray().size()) + if (!method.compare("eth_uninstallFilter") && f["args"].isArray() && f["args"].toArray().size()) + { + int idToRemove = f["args"].toArray()[0].toInt(); + m_watches.erase(std::remove(m_watches.begin(), m_watches.end(), idToRemove), m_watches.end()); + } + else if (!method.compare("eth_uninstallFilter") && f["args"].isArray() && f["args"].toArray().size()) { int idToRemove = f["args"].toArray()[0].toInt(); m_watches.erase(std::remove(m_watches.begin(), m_watches.end(), idToRemove), m_watches.end()); @@ -128,7 +133,7 @@ void QWebThree::onDataProcessed(QString _json, QString _addInfo) if (!_addInfo.compare("internal")) return; - if (!_addInfo.compare("changed")) + if (!_addInfo.compare("eth_changed")) { QJsonArray resultsArray = QJsonDocument::fromJson(_json.toUtf8()).array(); for (int i = 0; i < resultsArray.size(); i++) @@ -145,7 +150,7 @@ void QWebThree::onDataProcessed(QString _json, QString _addInfo) return; } - if (!_addInfo.compare("shhChanged")) + if (!_addInfo.compare("shh_changed")) { QJsonArray resultsArray = QJsonDocument::fromJson(_json.toUtf8()).array(); for (int i = 0; i < resultsArray.size(); i++) @@ -164,11 +169,11 @@ void QWebThree::onDataProcessed(QString _json, QString _addInfo) QJsonObject f = QJsonDocument::fromJson(_json.toUtf8()).object(); - if ((!_addInfo.compare("newFilter") || !_addInfo.compare("newFilterString")) && f.contains("result")) + if ((!_addInfo.compare("eth_newFilter") || !_addInfo.compare("eth_newFilterString")) && f.contains("result")) m_watches.push_back(f["result"].toInt()); - if (!_addInfo.compare("shhNewFilter") && f.contains("result")) + else if (!_addInfo.compare("shh_newFilter") && f.contains("result")) m_shhWatches.push_back(f["result"].toInt()); - if (!_addInfo.compare("newIdentity") && f.contains("result")) + else if (!_addInfo.compare("shh_newIdentity") && f.contains("result")) emit onNewId(f["result"].toString()); response(formatOutput(f));