cb-streams
stream-based interface to common-blockchain API
this module is used by Tradle
Usage
var through2 = require('through2')
var cbstreams = require('cb-streams')
var Blockchain = require('cb-blockr')
var blockchain = new Blockchain('testnet')
var blockstream = cbstreams.stream.blocks({
networkName: 'testnet',
api: blockchain
})
.pipe(through2.obj(function (blockInfo, enc, done) {
var block = blockInfo.block
}))
for (var i = 0; i < 10; i++) {
blockstream.write(i)
}
var txstream = cbstreams.stream.txs({
networkName: 'testnet',
api: blockchain
})
.pipe(through2.obj(function (txInfo, enc, done) {
var tx = txInfo.tx
}))
for (var i = 0; i < 10; i++) {
txstream.write(i)
}
var stream = cbstreams.stream.txs({
networkName: 'testnet',
api: blockchain,
addresses: [
'mvQx4yPAAzvZipC8mFWK1QUfPz1CNfnaBL',
'mk96Ff5754KUT7EGNKhvnTSdMpaPkuKU1N'
],
live: true
})
.pipe(through2.obj(function (txInfo, enc, done) {
var tx = txInfo.tx
}))