Browse Source

Squashed 'libjsqrc/ethereumjs/' changes from f3e1797..82cc5f6

82cc5f6 bring back jsonrpc single method calls in polling

git-subtree-dir: libjsqrc/ethereumjs
git-subtree-split: 82cc5f63aef10c2eb7896e2ecf9dbd0af3739785
cl-refactor
Marek Kotewicz 10 years ago
parent
commit
bba41eaeb5
  1. 31
      dist/ethereum.js
  2. 4
      dist/ethereum.js.map
  3. 2
      dist/ethereum.min.js
  4. 31
      lib/providermanager.js

31
dist/ethereum.js

@ -1043,33 +1043,16 @@ var ProviderManager = function() {
var self = this;
var poll = function () {
if (self.provider) {
var pollsBatch = self.polls.map(function (data) {
return data.data;
});
var payload = jsonrpc.toBatchPayload(pollsBatch);
var results = self.provider.send(payload);
self.polls.forEach(function (data, index) {
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;
}
self.polls.forEach(function (data) {
var result = self.send(data.data);
data.callback(result);
if (!(result instanceof Array) || result.length === 0) {
return;
}
});
data.callback(result);
});
}
setTimeout(poll, 1000);
};
poll();

4
dist/ethereum.js.map

File diff suppressed because one or more lines are too long

2
dist/ethereum.min.js

File diff suppressed because one or more lines are too long

31
lib/providermanager.js

@ -42,33 +42,16 @@ var ProviderManager = function() {
var self = this;
var poll = function () {
if (self.provider) {
var pollsBatch = self.polls.map(function (data) {
return data.data;
});
self.polls.forEach(function (data) {
var result = self.send(data.data);
var payload = jsonrpc.toBatchPayload(pollsBatch);
var results = self.provider.send(payload);
if (!(result instanceof Array) || result.length === 0) {
return;
}
self.polls.forEach(function (data, index) {
var result = results[index];
if (!jsonrpc.isValidResponse(result)) {
console.log(result);
return;
}
data.callback(result);
});
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);
};
poll();

Loading…
Cancel
Save