New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

blkdat-stream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blkdat-stream

A streamline blk*.dat stream module, useful for parsing the Bitcoin blockchain

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
11
175%
Maintainers
1
Weekly downloads
 
Created
Source

blkdat-stream

A lite blk*.dat streaming module, useful for parsing the Bitcoin blockchain

Example


var fs = require('fs')
var glob = require('glob')

var CombinedStream = require('combined-stream')
var BlkDatStream = require('../')

glob(process.env.BLOCKS_DIR + '/blk*.dat', function (err, fileNames) {
  if (err) throw err

  var cs = new CombinedStream()

  fileNames.forEach(function(fileName) {
    cs.append(fs.createReadStream(fileName, { mode: '0444' }))
  })

  var bds = new BlkDatStream()
  var j = 0
  bds.on('data', function(blockData) {
    console.log('>> Read block (', j, ')')
    j++

    // ... now, parse the block data buffer
  })

  cs.pipe(bds)
})

To parse the returned block data, use a library such as bitcoinjs-lib or bitcore

Keywords

blockchain

FAQs

Package last updated on 25 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts