Browse Source

whisper in alethzero

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
bab05f04ee
  1. 12
      alethzero/js/main.js
  2. 15
      libqethereum/QEthereum.cpp
  3. 4
      libweb3jsonrpc/WebThreeStubServer.cpp
  4. 12
      third/js/main.js

12
alethzero/js/main.js

@ -131,11 +131,11 @@
}).then(function (request) {
return new Promise(function (resolve, reject) {
web3.provider.send(request, function (result) {
if (result) {
if (result || typeof result === "boolean") {
resolve(result);
} else {
reject(result);
}
return;
}
reject(result);
});
});
}).catch(function( err) {
@ -373,6 +373,10 @@
});
};
Filter.prototype.arrived = function(callback) {
this.changed(callback);
}
Filter.prototype.changed = function(callback) {
var self = this;
this.promise.then(function(id) {

15
libqethereum/QEthereum.cpp

@ -151,14 +151,13 @@ void QWebThree::onDataProcessed(QString _json, QString _addInfo)
{
QJsonObject elem = resultsArray[i].toObject();
if (elem.contains("result"))
for (auto e: elem["result"].toArray())
{
QJsonObject res;
res["_event"] = _addInfo;
res["_id"] = (int)m_shhWatches[i];
res["data"] = e;
response(QString::fromUtf8(QJsonDocument(res).toJson()));
}
{
QJsonObject res;
res["_event"] = _addInfo;
res["_id"] = (int)m_shhWatches[i];
res["data"] = elem["result"].toArray();
response(QString::fromUtf8(QJsonDocument(res).toJson()));
}
}
}

4
libweb3jsonrpc/WebThreeStubServer.cpp

@ -155,7 +155,7 @@ static shh::Message toMessage(Json::Value const& _json)
if (!_json["to"].empty())
ret.setTo(jsToPublic(_json["to"].asString()));
if (!_json["payload"].empty())
ret.setPayload(jsToBytes(_json["payload"].asString()));
ret.setPayload(asBytes(_json["payload"].asString()));
return ret;
}
@ -216,7 +216,7 @@ static Json::Value toJson(h256 const& _h, shh::Envelope const& _e, shh::Message
res["workProved"] = (int)_e.workProved();
res["topic"] = toJS(_e.topic());
res["payload"] = toJS(_m.payload());
res["payload"] = asString(_m.payload());
res["from"] = toJS(_m.from());
res["to"] = toJS(_m.to());
return res;

12
third/js/main.js

@ -131,11 +131,11 @@
}).then(function (request) {
return new Promise(function (resolve, reject) {
web3.provider.send(request, function (result) {
if (result) {
if (result || typeof result === "boolean") {
resolve(result);
} else {
reject(result);
}
return;
}
reject(result);
});
});
}).catch(function( err) {
@ -373,6 +373,10 @@
});
};
Filter.prototype.arrived = function(callback) {
this.changed(callback);
}
Filter.prototype.changed = function(callback) {
var self = this;
this.promise.then(function(id) {

Loading…
Cancel
Save