cfnode

0.0.1 • Public • Published

CFNode - Compact Filters Node

A simple utility wrapper around bcoin to allow for an easy spin up of a light node for serving compact filters. This is similar to an SPV node in that it is stripped of most elements of a full node, except that it runs a blockchain index and a filter index. Running a pruned node, the database shouldn't be around > 10GB for mainnet as of March, 2019 (around 4.69GB for the chain and 4.14GB for the filters) and syncing shouldn't take more than a few days.

More info on compact, golomb coded set filters in Bitcoin can be found at the relevant BIPs 157 and 158.

Usage

From Command Line

To run from command line, install with git:

$ git clone https://github.com/bucko13/cfnode
$ cd cfnode
$ yarn install
$ ./bin/cfnode --pruned --checkpoints

Note that you can't retroactively turn on pruned or checkpoints for an existing chain database. If you find yourself in that position you can set a different prefix --prefix=[absolute path to location] or delete your existing chain db. Alternatively, just run ./bin/cfnode to use existing db setup. DBs are saved in bcoin's default location: ~/.bcoin.

As Library

$ yarn add cfnode
'use strict';

const {CFNode} = require('cfnode');

const node = new CFNode({
  memory: true,
  network: 'testnet',
  workers: true
});

(async () => {
  await node.open();
  await node.connect();

  node.on('connect', (entry, block) => {
    console.log('%s (%d) added to chain.', entry.rhash(), entry.height);
  });

  node.on('tx', (tx) => {
    console.log('%s added to mempool.', tx.txid());
  });

  node.startSync();
})().catch((err) => {
  console.error(err.stack);
  process.exit(1);
});

Configuration

Learn more about configuring bcoin here.

Contribution and License Agreement

If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work.

License

All code in this library is based on or directrly from existing code from bcoin

Readme

Keywords

none

Package Sidebar

Install

npm i cfnode

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

12.9 kB

Total Files

9

Last publish

Collaborators

  • bucko