aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-05-26 04:30:26 +0800
committerkumavis <aaron@kumavis.me>2018-05-26 04:30:26 +0800
commit9f8d5f05470d68a7a9a5474a5b1f4587398e94a3 (patch)
tree71e840bb5d5bfd91c580521f998ec5b4318e5099 /app
parent61ef4f1f29169c553b6a8fc36803e6f7596fc9ad (diff)
downloadtangerine-wallet-browser-9f8d5f05470d68a7a9a5474a5b1f4587398e94a3.tar
tangerine-wallet-browser-9f8d5f05470d68a7a9a5474a5b1f4587398e94a3.tar.gz
tangerine-wallet-browser-9f8d5f05470d68a7a9a5474a5b1f4587398e94a3.tar.bz2
tangerine-wallet-browser-9f8d5f05470d68a7a9a5474a5b1f4587398e94a3.tar.lz
tangerine-wallet-browser-9f8d5f05470d68a7a9a5474a5b1f4587398e94a3.tar.xz
tangerine-wallet-browser-9f8d5f05470d68a7a9a5474a5b1f4587398e94a3.tar.zst
tangerine-wallet-browser-9f8d5f05470d68a7a9a5474a5b1f4587398e94a3.zip
controllers - transactions - pending-tx-tracker - _getBlock - poll until block is truthy
Diffstat (limited to 'app')
-rw-r--r--app/scripts/controllers/transactions/pending-tx-tracker.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/scripts/controllers/transactions/pending-tx-tracker.js b/app/scripts/controllers/transactions/pending-tx-tracker.js
index bd26a72d9..e1bb67c90 100644
--- a/app/scripts/controllers/transactions/pending-tx-tracker.js
+++ b/app/scripts/controllers/transactions/pending-tx-tracker.js
@@ -1,6 +1,7 @@
const EventEmitter = require('events')
const log = require('loglevel')
const EthQuery = require('ethjs-query')
+const timeout = (duration) => new Promise(resolve => setTimeout(resolve, duration))
/**
Event emitter utility class for tracking the transactions as they<br>
@@ -212,7 +213,15 @@ class PendingTransactionTracker extends EventEmitter {
}
async _getBlock (blockNumber) {
- return await this.query.getBlockByNumber(blockNumber, false)
+ let block
+ while (!block) {
+ // block requests will sometimes return null due do the infura api
+ // being backed by multiple out-of-sync clients
+ block = await this.query.getBlockByNumber(blockNumber, false)
+ // if block is null, wait 1 sec then try again
+ if (!block) await timeout(1000)
+ }
+ return block
}
/**