Skip to content

Commit

Permalink
Copy block params for historical logs request
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke committed Mar 3, 2020
1 parent 64c1302 commit 7f3f42b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/web3-core-subscriptions/src/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,13 @@ Subscription.prototype.subscribe = function() {
// get past logs, if fromBlock is available
if(payload.params[0] === 'logs' && _.isObject(payload.params[1]) && payload.params[1].hasOwnProperty('fromBlock') && isFinite(payload.params[1].fromBlock)) {
// send the subscription request

// copy the params to avoid race-condition with deletion below this block
var blockParams = Object.assign({}, payload.params[1]);

this.options.requestManager.send({
method: 'eth_getLogs',
params: [payload.params[1]]
params: [blockParams]
}, function (err, logs) {
if(!err) {
logs.forEach(function(log){
Expand Down

0 comments on commit 7f3f42b

Please sign in to comment.