Browse Source

missing changes

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
78ea0fa766
  1. 4
      libjsqrc/main.js
  2. 29
      libqethereum/QEthereum.cpp

4
libjsqrc/main.js

@ -293,11 +293,11 @@
setupMethods(web3.shh, shhMethods()); setupMethods(web3.shh, shhMethods());
var ethWatch = { var ethWatch = {
changed: 'changed' changed: 'eth_changed'
}; };
setupMethods(ethWatch, ethWatchMethods()); setupMethods(ethWatch, ethWatchMethods());
var shhWatch = { var shhWatch = {
changed: 'shhChanged' changed: 'shh_changed'
}; };
setupMethods(shhWatch, shhWatchMethods()); setupMethods(shhWatch, shhWatchMethods());

29
libqethereum/QEthereum.cpp

@ -59,13 +59,13 @@ void QWebThree::poll()
{ {
if (m_watches.size() > 0) if (m_watches.size() > 0)
{ {
QString batch = toJsonRpcBatch(m_watches, "changed"); QString batch = toJsonRpcBatch(m_watches, "eth_changed");
emit processData(batch, "changed"); emit processData(batch, "eth_changed");
} }
if (m_shhWatches.size() > 0) if (m_shhWatches.size() > 0)
{ {
QString batch = toJsonRpcBatch(m_shhWatches, "shhChanged"); QString batch = toJsonRpcBatch(m_shhWatches, "shh_changed");
emit processData(batch, "shhChanged"); emit processData(batch, "shh_changed");
} }
} }
@ -73,13 +73,13 @@ void QWebThree::clearWatches()
{ {
if (m_watches.size() > 0) if (m_watches.size() > 0)
{ {
QString batch = toJsonRpcBatch(m_watches, "uninstallFilter"); QString batch = toJsonRpcBatch(m_watches, "eth_uninstallFilter");
m_watches.clear(); m_watches.clear();
emit processData(batch, "internal"); emit processData(batch, "internal");
} }
if (m_shhWatches.size() > 0) if (m_shhWatches.size() > 0)
{ {
QString batch = toJsonRpcBatch(m_shhWatches, "shhUninstallFilter"); QString batch = toJsonRpcBatch(m_shhWatches, "shh_uninstallFilter");
m_shhWatches.clear(); m_shhWatches.clear();
emit processData(batch, "internal"); emit processData(batch, "internal");
} }
@ -106,7 +106,12 @@ void QWebThree::postMessage(QString _json)
QJsonObject f = QJsonDocument::fromJson(_json.toUtf8()).object(); QJsonObject f = QJsonDocument::fromJson(_json.toUtf8()).object();
QString method = f["call"].toString(); 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(); int idToRemove = f["args"].toArray()[0].toInt();
m_watches.erase(std::remove(m_watches.begin(), m_watches.end(), idToRemove), m_watches.end()); 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")) if (!_addInfo.compare("internal"))
return; return;
if (!_addInfo.compare("changed")) if (!_addInfo.compare("eth_changed"))
{ {
QJsonArray resultsArray = QJsonDocument::fromJson(_json.toUtf8()).array(); QJsonArray resultsArray = QJsonDocument::fromJson(_json.toUtf8()).array();
for (int i = 0; i < resultsArray.size(); i++) for (int i = 0; i < resultsArray.size(); i++)
@ -145,7 +150,7 @@ void QWebThree::onDataProcessed(QString _json, QString _addInfo)
return; return;
} }
if (!_addInfo.compare("shhChanged")) if (!_addInfo.compare("shh_changed"))
{ {
QJsonArray resultsArray = QJsonDocument::fromJson(_json.toUtf8()).array(); QJsonArray resultsArray = QJsonDocument::fromJson(_json.toUtf8()).array();
for (int i = 0; i < resultsArray.size(); i++) 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(); 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()); 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()); 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()); emit onNewId(f["result"].toString());
response(formatOutput(f)); response(formatOutput(f));

Loading…
Cancel
Save