Skip to content
Permalink
Browse files

add check process block

  • Loading branch information...
khaihkd committed Jul 23, 2018
1 parent f24ec59 commit cc4ff3515df024501f1a23f436ba257a4310f1f7
Showing with 10 additions and 5 deletions.
  1. +10 −5 crawl.js
@@ -6,7 +6,7 @@ const web3 = require('./models/blockchain/chain')

let sleep = (time) => new Promise((resolve) => setTimeout(resolve, time))

async function process() {
async function crawlProcess() {
for (let i = 5168958; i < 5995800 ; i++) {
if (i !== 5168958 && i !== 5169011 && i !== 5169173 && i < 5175169) {
continue
@@ -17,13 +17,18 @@ async function process() {
}

let block = await web3.eth.getBlock(i);
await new db.Block({
let b = await db.Block.findOne({blockNumber: i})
if (b && b.isProcess) {
continue
}
await db.Block.findOneAndUpdate({blockNumber: block.number}, {
hash: block.hash,
blockNumber: block.number,
transactionCount: block.transactions.length,
parentHash: block.parentHash,
timestamp: block.timestamp
}).save()
timestamp: block.timestamp,
isProcess: true
}, { upsert: true, new: true })

console.log("Process block number: " + i);
let listTransactions = await block.transactions
@@ -34,4 +39,4 @@ async function process() {
}
}

process()
crawlProcess()

0 comments on commit cc4ff35

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