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

libp2p-pstn-logger

v0.0.2

Published

A data logger for benchmarking libp2p pubsub implementations

Downloads

11

Readme

js libp2p pstn logger

A test data logger for benchmarking libp2p pubsub implementations.

Install

To install through npm:

> npm i libp2p-pstn-logger --save

Example

libp2p-pstn-logger is built to work with this early implementation of libp2p pubsub. It simply proxies a Pubsub instance's function calls and adds the new log events necessary for the testnet benchmark tools.

It logs using debug and its namespace is pstn:logger*.

const Pubsub = require('libp2p-floodsub')
const libp2p = require('libp2p-ipfs')
const addLogger = require('libp2p-pstn-logger')

const p2p = new libp2p.Node(<somePeerInfo>)
const pubsub = PS(p2p)

// Now just proxy and log the important pubsub events by calling the fn
addLogger(pubsub, p2p.peerInfo.id.toB58String())

// Or if you want to work with a logger instance, simply create one.
// const logger = addLogger(pubsub, p2p.peerInfo.id.toB58String())
// ...
// logger.on('publish', <your handler>)

Proxied Pubsub Log Events

The proxied pubsub instance will now dump the following events to any specified log file in this format.

  • <timestamp> pstn:logger publish <b58_event_source_id> <b64_topic> <b64_msg>
  • <timestamp> pstn:logger receive <b58_event_source_id> <b64_topic> <b64_msg>
  • <timestamp> pstn:logger subscribe <b58_event_source_id> <b64_topic> <b64_msg>
  • <timestamp> pstn:logger unsubscribe <b58_event_source_id> <b64_topic> <b64_msg>

Logger Instance Events

Logger instances will receive these events:

  • logger.on('publish', <handler>)
  • logger.on('receive', <handler>)
  • logger.on('subscribe', <handler>)
  • logger.on('unsubscribe', <handler>)

Logger Instance Event Structure

Test log events are JSON objects structured as follows:

{
  timestamp: <milliseconds>, // time of event capture in the pubsub instance
  source: <libp2p_peer_id_base58_string>, // E.g.: libp2pNode.peerInfo.id.toB58String()
  type: <string>, // publish, subscribe, unsubscribe, receive
  args: <array_args_for_proxied_fn>
}

API

Logger Instance

logger.on('publish', <handler>)

logger.on('receive', <handler>)

logger.on('subscribe', <handler>)

logger.on('unsubscribe', <handler>)

Tests

To run the basic tests:

> npm test

To dump the debug logs into a file for viewing/parsing:

> npm run test:log

To show the debug logs:

> npm run test:debug

Contribute

PRs are welcome!

License

MIT © Gavin McDermott