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

ssb-partial-replication

v3.0.1

Published

ssb partial replication helper functions

Downloads

8

Readme

SSB partial replication

A collection of functions useful for replicating a part of the log instead of everything. This is superseeded by SSB secure partial replication.

api

getFeed({id: feedId, seq: int?, live: bool?, limit: int?, keys: bool?, values: bool?}) -> PullSource

The method has exactly the same interface as createHistoryStream because it just wraps the function. It is much faster though. See appendix for more information.

getFeedReverse({id: feedId, seq: int?, live: bool?, limit: int?, keys: bool?, values: bool?}) -> PullSource

This function does the same as getFeed except if one does not specify seq the latest sequence for the feed with be fetched and used. This allows one to get the latest X messages from a feed using the limit option without knowing how many messages the feed currently has.

getTangle(msgId, cb)

Get all the messages of a tangle given a root message id. This can be used to fetch threads or similar tangles. This is similar in spirit to ssb-ooo except there is no protocol involved to fetch messages from other nodes.

getMessagesOfType({id: feedId, type: string, seq: int?, limit: int?}) -> PullSource

Get messages of a particular type for a feed. This can be used to fetch say all contact messages for a particular feed to construct the social graph without having to download all the messages of the feed.

Appendix

There is something wrong with createHistoryStream over a network connection. Locally it takes around 600ms, using net protocol the same call takes 6.500ms and using ws the exact same call takes 20.000ms?

var pull = require('pull-stream')

var remote = 'ws:between-two-worlds.dk:8989~shs:lbocEWqF2Fg6WMYLgmfYvqJlMfL7hiqVAV6ANjHWNw8=.ed25519'
//remote = 'net:between-two-worlds.dk:8008~shs:lbocEWqF2Fg6WMYLgmfYvqJlMfL7hiqVAV6ANjHWNw8=.ed25519'

require('ssb-client')({ remote }, (err, sbot) => {
  if (err) throw err
  console.time("downloading messages")
  pull(
    sbot.createHistoryStream({id: '@ye+QM09iPcDJD6YvQYjoQc7sLF/IFhmNbEqgdzQo3lQ=.ed25519', seq: 27000, keys: false}),
    pull.drain((msg) => {
      console.log(msg)
    }, (err) => {
      if (err) throw err

      console.timeEnd("downloading messages")
      sbot.close()
    })
  )
})

The problem seems to be buried in the legacy protocol for ssb-replication somewhere.

This module simply exposes createHistoryStream as partialReplication without any of the legacy overhead and we are back to 600ms again.