Skip to content
Permalink
Browse files

update crawl process

  • Loading branch information...
khaihkd committed Jul 24, 2018
1 parent bd4d78c commit cc84dd66da12468a50dadaddd3542486c29f0ae0
Showing with 5 additions and 4 deletions.
  1. +5 −4 crawl.js
@@ -12,8 +12,8 @@ async function crawlProcess() {
continue
}
if (i % 10 === 0) {
console.log('Sleep 10 seconds')
await sleep(10000)
console.log('Sleep 120 seconds')
await sleep(120000)
}

let block = await web3.eth.getBlock(i);
@@ -27,14 +27,15 @@ async function crawlProcess() {
transactionCount: block.transactions.length,
parentHash: block.parentHash,
timestamp: block.timestamp,
isProcess: true
}, { upsert: true, new: true })

console.log("Process block number: " + i);
let listTransactions = await block.transactions
if (listTransactions != null && block != null) {
await q.create('newTransaction', {transactions: listTransactions.toString(), blockNumber: block.number})
.priority('normal').removeOnComplete(true).save()
.attempts(5).backoff({delay: 10000})
.priority('low').removeOnComplete(true).save()
await db.Block.findOneAndUpdate({blockNumber: i}, {isProcess: true}, { upsert: true, new: true })
}
}
}

0 comments on commit cc84dd6

Please sign in to comment.
You can’t perform that action at this time.