Skip to content

Commit

Permalink
fix(newBlockHeaders): Add delay before getting block
Browse files Browse the repository at this point in the history
  • Loading branch information
morrislaptop committed Mar 14, 2018
1 parent 71fc5b8 commit 2f6e5f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 861 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"private": false,
"devDependencies": {
"bignumber.js": "https://github.com/frozeman/bignumber.js-nolookahead.git",
"bluebird": "^3.5.1",
"chai": "^4.1.2",
"chai-bignumber": "^2.0.2",
"ganache-cli": "^6.1.0-beta.4",
Expand All @@ -21,11 +20,13 @@
"vue": "^2.5.13"
},
"scripts": {
"dev": "microbundle watch",
"build": "microbundle",
"test": "truffle test",
"prepublishOnly": "yarn build"
},
"dependencies": {
"bluebird": "^3.5.1",
"lodash": "^4.17.5",
"web3": "^1.0.0-beta.30"
}
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Web3 = require('web3')
const Promise = require('bluebird')
const _ = require('lodash')

module.exports = (Vue, options) => {
Expand All @@ -13,6 +14,8 @@ module.exports = (Vue, options) => {
async function onNewBlockHeaderData(blockHeader) {
if (! blockHeader.number) return

await Promise.delay(12000) // allow node to get the txns in the block

let block = await web3.eth.getBlock(blockHeader.number, true)

let addressesToCheck = callsToCheck.map(call => call.contract.options.address)
Expand Down
Loading

0 comments on commit 2f6e5f1

Please sign in to comment.