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

@savid/libp2p-pest

v1.1.0

Published

Get the [status](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#status) of a [libp2p](https://libp2p.io/) peer via the [Node Discovery Protocol v5](https://github.com/ethereum/devp2p/blob/master/discv5/discv5.md).

Downloads

4

Readme

@savid/libp2p-pest

Get the status of a libp2p peer via the Node Discovery Protocol v5.

This package is adapted from the @chainsafe/discv5 project.

Requirements

  • NodeJS v18+
  • ESM only

Limitations

Currently only support an ENR with tcp4 multiaddr.

Install

npm install --save @savid/libp2p-pest

Usage

import pest from '@savid/libp2p-pest';

try {
  const status = await pest({
    enr: 'enr:-IS4QLkKqDMy_ExrpOEWa59NiClemOnor-krjp4qoeZwIw2QduPC-q7Kz4u1IOWf3DDbdxqQIgC4fejavBOuUPy-HE4BgmlkgnY0gmlwhCLzAHqJc2VjcDI1NmsxoQLQSJfEAHZApkm5edTCZ_4qps_1k_ub2CxHFxi-gr2JMIN1ZHCCIyg',
  });
} catch (error) {
  console.log('something happened', error.code);
}

API

function pest(options: {
  // ETHEREUM NODE RECORDS (ENRS) https://ethereum.org/en/developers/docs/networking-layer/network-addresses/#enr
  enr: string;
}): Response;

// status https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#status
type Response = {
  // fork digest of peer
  forkDigest: string;
  // state.finalized_checkpoint.root for the state corresponding to the head block
  finalizedRoot: string;
  // state.finalized_checkpoint.epoch for the state corresponding to the head block
  finalizedEpoch: number;
  // the hash_tree_root root of the current head block (BeaconBlock)
  headRoot: string;
  // the slot of the block corresponding to the head_root
  headSlot: number;
};

example response;

{
  forkDigest: '0x36fa5013',
  finalizedRoot: '0x35b8f3cc8cd912056d45541573d02475379a98b7ed40c7672dfd225b0fd166e7',
  finalizedEpoch: 17193,
  headRoot: '0x35b8f3cc8cd912056d45541573d02475379a98b7ed40c7672dfd225b0fd166e7',
  headSlot: 550176
}

Error codes

| Reason | Meaning | |----------------------------------- |:------------------------------------------------| | SECP256K1_PEER_ID_FAILED | Failed to generate secp256k1 peer id | | LIBP2P_START_FAILED | Failed to start libp2p instance | | MALFORMED_ENR | Malformed ENR provided | | NO_VALID_MULTIADDR | No valid tcp4 multiaddr in ENR provided | | LIBP2P_DIALIER_NODE_START_FAILED | Failed to start libp2p dialer node | | LIBP2P_DIALIER_DIAL_FAILED | Failed to dial out with libp2p dialer | | PEER_STATUS_FAILED | Failed to receive peer status | | PEER_STATUS_NOT_SUCCESSFUL | Received non success status header | | PEER_STATUS_SSZ_LENGTH_INVALID | Peer status SSZ length invalid | | PEER_STATUS_SSZ_LENGTH_TOO_LARGE | Peer status SSZ length too large | | PEER_STATUS_SSZ_LENGTH_TOO_SMALL | Peer status SSZ length too small | | PEER_STATUS_IDENTIFIER_INVALID | Peer status identifier invalid | | PEER_STATUS_CHUNK_TYPE_INVALID | Peer status chunk type invalid |

License

MIT