bring back jsonrpc single method calls in polling

This commit is contained in:
Marek Kotewicz 2015-02-05 18:20:43 +01:00
parent f3e1797153
commit 82cc5f63ae
4 changed files with 17 additions and 51 deletions

31
dist/ethereum.js vendored
View File

@ -1043,33 +1043,16 @@ var ProviderManager = function() {
var self = this; var self = this;
var poll = function () { var poll = function () {
if (self.provider) { self.polls.forEach(function (data) {
var pollsBatch = self.polls.map(function (data) { var result = self.send(data.data);
return data.data;
});
var payload = jsonrpc.toBatchPayload(pollsBatch); if (!(result instanceof Array) || result.length === 0) {
var results = self.provider.send(payload); return;
}
self.polls.forEach(function (data, index) { data.callback(result);
var result = results[index]; });
if (!jsonrpc.isValidResponse(result)) {
console.log(result);
return;
}
result = result.result;
// dont call the callback if result is not an array, or empty one
if (!(result instanceof Array) || result.length === 0) {
return;
}
data.callback(result);
});
}
setTimeout(poll, 1000); setTimeout(poll, 1000);
}; };
poll(); poll();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -42,33 +42,16 @@ var ProviderManager = function() {
var self = this; var self = this;
var poll = function () { var poll = function () {
if (self.provider) { self.polls.forEach(function (data) {
var pollsBatch = self.polls.map(function (data) { var result = self.send(data.data);
return data.data;
});
var payload = jsonrpc.toBatchPayload(pollsBatch); if (!(result instanceof Array) || result.length === 0) {
var results = self.provider.send(payload); return;
}
self.polls.forEach(function (data, index) { data.callback(result);
var result = results[index]; });
if (!jsonrpc.isValidResponse(result)) {
console.log(result);
return;
}
result = result.result;
// dont call the callback if result is not an array, or empty one
if (!(result instanceof Array) || result.length === 0) {
return;
}
data.callback(result);
});
}
setTimeout(poll, 1000); setTimeout(poll, 1000);
}; };
poll(); poll();