Skip to content
Permalink
Browse files

crawl signers, random from header

  • Loading branch information...
thanhson1085 committed Apr 3, 2019
1 parent cd01938 commit 99513523db3da4b416b5c9234bda10237afe41f2
Showing with 603 additions and 569 deletions.
  1. +25 −0 commands/epoch.js
  2. +577 −569 package-lock.json
  3. +1 −0 package.json
@@ -82,10 +82,35 @@ async function report (data) {
}
}

async function getSigners (epochNumber) {
let checkpoint = (epochNumber - 1) * 900
let block = await web3Rpc.eth.getBlock(checkpoint)
let buff = Buffer.from(block.extraData.substring(2), 'hex')
let sbuff = buff.slice(32, buff.length - 65)
let signers = []
if (sbuff.length > 0) {
for (let i = 1; i <= sbuff.length / 20; i++) {
let address = sbuff.slice((i - 1) * 20, i * 20)
signers.push('0x' + address.toString('hex'))
}
}

buff = Buffer.from(block.validators.substring(2), 'hex')
let randoms = []
for (let i = 1; i <= buff.length / 4; i++) {
let k = buff.slice((i - 1) * 4, i * 4)
randoms.push(web3Rpc.utils.hexToUtf8('0x' + k.toString('hex')))
}
return { signers, randoms }
}

async function run (epochNumber) {
let start = (epochNumber - 1) * 900 + 1
let end = epochNumber * 900

let { signers, randoms } = await getSigners(epochNumber)
logger.info(`signers ${signers} randoms ${randoms}`)

let data = []
for (let i=start; i<=end; i++) {
let it = await scan(i)
Oops, something went wrong.

0 comments on commit 9951352

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