npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

coindjs-bootstrap

v0.0.1

Published

Bootstrap bitcoin-based systems using IRC or DNS seeds.

Downloads

6

Readme

CoinDJs - Bootstrap

This is the bootstrap component of CoinDJs, a bitcoin (namecoin and ilk) full node and library.

Bootstrapping allows the peer-to-peer network to discover its initial set of peers to connect to, and has a couple methods:

  • DNS - Connects to a set of trusted seed domain names to get a list of peers
  • IRC - Connects to a given IRC (Internet Relay Chat) channel to announce and seek peers

Install

npm install coindjs-bootstrap

Connecting to DNS Seeds

This is the method bitcoind uses today, which operates against a list of trusted DNS seeds included in the bitcoind source code.

var bootstrap = require('./index.js');

var seeds = [
    "seed.bitcoin.sipa.be",
    "dnsseed.bluematt.me",
    "dnsseed.bitcoin.dashjr.org",
    "seed.bitcoinstats.com",
    "seed.bitnodes.io",
    "bitseed.xf2.org"
];

// Connect to several DNS seeds
var dnsBootstrap = new bootstrap.DNS(seeds, 8333);
dnsBootstrap.on('found', function(addresses) {
    console.log("Found: ", addresses);
});
dnsBootstrap.on('updated', function(addresses) {
    console.log("Updated:", addresses);
});

// Query a single DNS seed for some addresses
bootstrap.DNS.query(seeds[0], 8333, function (error, addresses) {
    console.log("Found:", addresses);
});

Connecting to IRC

This method is no longer used by the Bitcoin network, but is still popular with alt-coins that were forked from bitcoind quite early on, such as Namecoin.

// Bitcoin once upon a time used #bitcoin00 through #bitcoin99
// Namecoin still uses #nmaecoin00 through #namecoin1
function randomNamecoinChannel() {
    return '#namecoin0' + parseInt(Math.random() * 2);
}

// Connect to IRC and set our address
var ircBootstrap = new bootstrap.IRC(randomNamecoinChannel(), '127.0.0.1', 8334);

// We have found some addresses
ircBootstrap.on('found', function(addresses) {
    console.log("Found:", addresses);
});

// Updated is always triggered, even for the initial addresses
ircBootstrap.on('updated', function(users) {
    console.log("Updated:", users);
});

// Convert a nickname to an address
var nickname = 'u88qSoM5z6w9QqB';
console.log(bootstrap.IRC.nicknameToAddress(nickname));

// Convert an address to a nickname
var host = '127.0.0.1', port = 8334;
console.log(bootstrap.IRC.addressToNickname(host, port));

// Give the server a moment to run (it does not stop the node instance from terminating)
setTimeout(function() { }, 3000);

Found vs Updated events

The found event is emitted the first time any addresses are found; services which only care about any initial set of peers can listen for this event.

The updated event is emitted whenever any new addresses are found, including the above found event.

Testing

For now, there is a test.js that does basic/manual sanity checks... More testing coming soon.

Donations?

Obviously, it's all licensed under the MIT license, so use it as you wish; but if you'd like to buy me a coffee, I won't complain. =)

  • Bitcoin - 1Fio5rkqduaH5p47Kb9nKSHyHn1swqQiJK
  • Dogecoin - DMuMsChNgLb3kMqSJFqqYTfZNnbPZkcs3z
  • Testnet3 - n2JD7JZ6y32C1DMvA5h7FzeBRNA15FQPdH