From 8087548edf3d51af852e6b34b7dd20467169e38e Mon Sep 17 00:00:00 2001 From: wulfraem Date: Tue, 24 Sep 2019 09:09:05 +0200 Subject: [PATCH 1/2] fix missing blocks from infura in signer tx handling - [CORE-528] --- VERSIONS.md | 1 + src/contracts/signer-internal.ts | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/VERSIONS.md b/VERSIONS.md index 5e7a681..f253a0a 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -4,6 +4,7 @@ ### Features ### Fixes +- fix missing blocks, that could not be retrieved after `newBlockHeaders` was triggered ### Deprecations diff --git a/src/contracts/signer-internal.ts b/src/contracts/signer-internal.ts index 0e7485b..30e9e44 100644 --- a/src/contracts/signer-internal.ts +++ b/src/contracts/signer-internal.ts @@ -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); } }); } From c8c11249eefc45cd0f10910f4289feb1eaf0a6ed Mon Sep 17 00:00:00 2001 From: wulfraem Date: Tue, 8 Oct 2019 10:21:55 +0200 Subject: [PATCH 2/2] release v1.8.3 - [CORE-526] --- VERSIONS.md | 6 +++++- package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/VERSIONS.md b/VERSIONS.md index f253a0a..61fb8d3 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -4,11 +4,15 @@ ### Features ### Fixes -- fix missing blocks, that could not be retrieved after `newBlockHeaders` was triggered ### 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` diff --git a/package.json b/package.json index 1fd2897..c55531e 100644 --- a/package.json +++ b/package.json @@ -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" } \ No newline at end of file