Last active
May 15, 2020 13:46
-
-
Save pinheadmz/a2cd8d6d32ae6c5fab75eb41497f070a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const {NodeClient} = require('hs-client'); | |
| const {Network} = require('hsd'); | |
| const network = Network.get('main'); | |
| const nodeOptions = { | |
| network: network.type, | |
| port: network.rpcPort | |
| }; | |
| const nodeClient = new NodeClient(nodeOptions); | |
| (async () => { | |
| await nodeClient.open(); | |
| let height = 0; | |
| const map = new Map(); | |
| for(;;) { | |
| const block = await nodeClient.getBlock(height); | |
| if (!block) | |
| break; | |
| for (let i = 0; i < block.txs.length; i++) { | |
| const tx = block.txs[i]; | |
| for (let j = 0; j < tx.outputs.length; j++) { | |
| const output = tx.outputs[j]; | |
| let action = output.covenant.action; | |
| if (i === 0 && j > 0 && action !== 'CLAIM') { | |
| if (tx.inputs[j].witness[0].length > 900) | |
| action = 'AIRDROP'; | |
| else | |
| action = 'FAUCET'; | |
| } | |
| if (i === 0 && j === 0) | |
| action = 'COINBASE'; | |
| const curr = map.get(action) | |
| if (!curr){ | |
| const det = new Map(); | |
| det.set('count', 1); | |
| det.set('value', output.value); | |
| map.set(action, det); | |
| } else { | |
| curr.set('count', curr.get('count') + 1); | |
| curr.set('value', curr.get('value') + output.value); | |
| } | |
| } | |
| } | |
| console.log(block.height, map); | |
| height++; | |
| } | |
| process.exit(0); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.