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

orbit-db-powergate-io

v0.2.1

Published

> A bridge between [OrbitDB](https://github.com/orbitdb/orbit-db) and [Powergate](https://docs.textile.io/powergate/), which is itself a bridge between [Filecoin](https://filecoin.io) and [IPFS](https://ipfs.io/).

Downloads

9

Readme

PowergateIO (orbit-db-powergate-io)

A bridge between OrbitDB and Powergate, which is itself a bridge between Filecoin and IPFS.

Install

npm install orbit-db-powergate-io

From Source

$ git clone https://github.com/orbitdb/orbit-db-powergate-io
$ cd orbit-db-powergate-io
$ npm install

Usage

PowergateIO is designed to work with only one configuration option: the gRPC endpoint of the Powergate node you want to connect to. Everything else should be handled "under the hood" for you. See below.

Initial Setup

const PowergateIO = require('orbit-db-powergate-io')

const host = 'http://0.0.0.0:6002' // This is the default value
PowergateIO.create(host)
  .then((powergateio) => {
    console.log(powergateio.wallet) // Will be {} until funded
  })

Backing up an OrbitDB Snapshot

PowergateIO is meant to be used from one IPFS node to another, and to replicate OrbitDB databases between them. So, let's assume that we have an IPFS node and OrbitDB running locally, and we're going to interact with a remote Powergate instance.

const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
const PowergateIO = require('orbit-db-powergate-io')

;(async () => {
  const ipfs = await IPFS.create()
  const orbitdb = await OrbitDB.createInstance(ipfs)
  powergateio = await PowergateIO.create('https://my.hosted.powergate.node')

  const addresses = (await powergateio.ipfs.id()).addresses
  await ipfs.swarm.connect(addresses[0].toString())

  const db = await orbitdb.eventlog('powergate-test')
  for (let i = 0; i < 10; i++) {
    await db.add(`entry${i}`)
  }

  jobStatus = await powergateio.storeSnapshot(db.address.toString())
  console.log(jobStatus)

  // Wait until wallet is funded
  // Can take up to 2 minute on testnet
  console.log(powergateio.wallet)

  await powergateio.stop()
  await orbitdb.disconnect()
  await ipfs.stop()
})()

Retrieving an OrbitDB Snapshot

Once you've stored a snapshot and have made note of the DB address returned, you can use that db address to retrieve the snapshot!

const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
const PowergateIO = require('orbit-db-powergate-io')

;(async () => {
  const ipfs = await IPFS.create()
  const orbitdb = await OrbitDB.createInstance(ipfs)
  const powergateio = await PowergateIO.create('https://my.hosted.powergate.node')

  const addresses = (await powergateio.ipfs.id()).addresses
  await ipfs.swarm.connect(addresses[0].toString())

  const dbAddr = '/orbitdb/zdpuAxkdoDum8Nk2VCxKkHZk8TzqAYPm86mVgoy7wagu2UcZB/powergate-test'
  const db2 = await orbitdb.open(dbAddr, { create: true })
  const snapshot = await powergateio.retrieveSnapshot(dbAddr)

  await db2._oplog.join(snapshots[0].log)
  await db2._updateIndex()
})()

For more information, see the API docs. Also, the tests are heavily commented to detail what is happening at each step.

Contributing

Issues and pull requests accepted. Please note that several issues have "Help Wanted" and "Good First Issue" tags!

Developing Locally

It's highly recommended to install both Docker and Docker compose. From there, make is your best friends. It gives you the following commands:

  • make up - Spins up all the necessary docker images for local development
  • make lint - Lints your JS code vi standard.js
  • make docs - Compiles the README and JS docstrings into the docs/ folder
  • make down - Spins down all the docker images
  • make clean - Removes ephemeral files and folders like node_modules and package-lock.json
  • make test - Does a whole bunch of the above, in order. use it!
  • make rebuild - runs make clean and make deps to give you a clean slate.

License

MIT (or Apache2.0 at your discretion)

© OrbitDB Community