Skip to content

Commit

Permalink
Merge branch 'release/v1.8.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
wulfraem committed Oct 8, 2019
2 parents fca9f2f + c8c1124 commit cce46a8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
5 changes: 5 additions & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
### Deprecations


## Version 1.8.3
### Fixes
- fix missing blocks, that could not be retrieved after `newBlockHeaders` was triggered


## Version 1.8.2
### Fixes
- fix missing `SignerSignedMessage`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@
"testunitbrk": "npm run build && mocha --inspect-brk -r ts-node/register $*"
},
"types": "./dist/index.d.ts",
"version": "1.8.2"
"version": "1.8.3"
}
27 changes: 18 additions & 9 deletions src/contracts/signer-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,25 @@ export class SignerInternal extends Logger implements SignerInterface {

// only load block details, when pending transactions are open
if (pendingTransactionHashes.length !== 0) {
const blockDetails = await this.web3.eth.getBlock(blockHeader.number);

// iterate through all pending transactions and check if transaction was finished
Object.keys(this.pendingTransactions).forEach((transactionHash: string) => {
// if transaction was finished, call all the callbacks and delete the subscription
if (blockDetails.transactions.indexOf(transactionHash) !== -1) {
this.pendingTransactions[transactionHash].forEach(callback => callback(blockHeader));
delete this.pendingTransactions[transactionHash];
const blockNumber = blockHeader.number;
const blockStart = Date.now();
const checkInterval = setInterval(async () => {
this.log(`checking for block ${blockNumber}`, 'debug');
const blockDetails = await this.web3.eth.getBlock(blockHeader.number);
if (blockDetails) {
clearInterval(checkInterval);
this.log(`received block details for block ${blockNumber} after ${Date.now() - blockStart}ms`, 'debug');

// iterate through all pending transactions and check if transaction was finished
Object.keys(this.pendingTransactions).forEach((transactionHash: string) => {
// if transaction was finished, call all the callbacks and delete the subscription
if (blockDetails.transactions.indexOf(transactionHash) !== -1) {
this.pendingTransactions[transactionHash].forEach(callback => callback(blockHeader));
delete this.pendingTransactions[transactionHash];
}
});
}
});
}, 500);
}
});
}
Expand Down

0 comments on commit cce46a8

Please sign in to comment.