# bcoin-zeromq

> A zeromq plugin for bcoin

Latest version **0.0.5** (published 2017-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install bcoin-zeromq
pnpm add bcoin-zeromq
yarn add bcoin-zeromq
bun add bcoin-zeromq
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2017-04-18 |
| First published | 2017-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | homeopatchy |
| Maintainers | homeopatchy |
| Keywords | bcoin, plugin, zeromq, zmq |

## Links

- npm: https://www.npmjs.com/package/bcoin-zeromq
- npm.io page: https://npm.io/package/bcoin-zeromq

## Dependencies (1)

- [zeromq](https://npm.io/package/zeromq.md) ^4.2.1

## Recent versions

- 0.0.5 (latest) — 2017-04-18
- 0.0.4 — 2017-04-18
- 0.0.3 — 2017-04-18
- 0.0.2 — 2017-04-18
- 0.0.1 — 2017-04-18

## README

# bcoin-zeromq
### A zeromq plugin for bcoin

## Motivation

Some bitcoin applications (such as [bitcore-node](https://github.com/bitpay/bitcore-node)) currently hook to bitcoin core's zeromq sockets to fetch incoming blocks and transactions. This plugin aims to bring such functionality to bcoin.

## Usage 

Currently bcoin provides no funcionality to install and load global plugins, so in order to use this one you'll need to run it from a dedicated project directory:

```shell
mkdir mynode
cd mynode && npm init
npm install --save bcoin bcoin-zeromq
```

Then just create `index.js` with the following contents to load the node:

```js
const FullNode = require('bcoin/lib/node/fullnode')
const ZeroMQ = require('bcoin-zeromq')

const ZMQ_ADDRESS = 'tcp://127.0.0.1:28332'

const node = new FullNode({
  db: 'memory',
  zmqPubRawTx: ZMQ_ADDRESS,
  zmqPubHashTx: ZMQ_ADDRESS,
  zmqPubRawBlock: ZMQ_ADDRESS,
  zmqPubHashBlock: ZMQ_ADDRESS
})

node.use(ZeroMQ)

node.open()
  .then(() => node.connect())
  .then(() => node.startSync())
```

A subscriber may then start receiving block and transaction data. Here's an example using [zeromq](https://www.npmjs.com/package/zeromq):

```js
const zeromq = require('zeromq')

const ZMQ_ADDRESS = 'tcp://127.0.0.1:28332'
const ZMQ_TOPIC = 'hashblock'

const subscriber = zeromq.socket('sub')

subscriber.connect(ZMQ_ADDRESS)
subscriber.subscribe(ZMQ_TOPIC)

subscriber.on('message', (topic, msg) => {
  console.log('%s %s', topic, msg)
})
```

---
_Source: https://npm.io/package/bcoin-zeromq · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
