How to use the orbit-db function in orbit-db

To help you get started, we’ve selected a few orbit-db examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OriginProtocol / origin / origin-messaging / src / index.js View on Github external
const startOrbitDbServer = async ipfs => {
  // Remap the peer connected to ours which will wait before exchanging heads
  // with the same peer
  const orbitGlobal = new OrbitDB(ipfs, config.ORBIT_DB_PATH, {
    keystore: new InsertOnlyKeystore()
  })

  orbitGlobal._onPeerConnected = _onPeerConnected

  orbitGlobal.keystore.registerSignVerify(
    config.GLOBAL_KEYS,
    undefined,
    verifyRegistrySignature,
    message => {
      handleGlobalRegistryWrite(orbitGlobal, message.payload)
    }
  )

  const globalRegistry = await orbitGlobal.kvstore(config.GLOBAL_KEYS, {
    write: ['*']
github OriginProtocol / origin / js / messaging / orbit_server.js View on Github external
ipfs.on("ready", async () => {
  // remap the peer connected to ours which will wait before exchanging heads with the same peer
  const orbit_global = new OrbitDB(ipfs, "odb/Main", {keystore:new InsertOnlyKeystore()})
  orbit_global._onPeerConnected = _onPeerConnected
  ipfs.setMaxListeners(MAX_IPFS_CONNECTIONS)

  orbit_global.keystore.registerSignVerify(GLOBAL_KEYS, undefined, verifyRegistrySignature, message => {
    handleGlobalRegistryWrite(orbit_global, message.payload)
  })

  const global_registry = await orbit_global.kvstore(GLOBAL_KEYS, { write: ['*'] })
  rebroadcastOnReplicate(orbit_global, global_registry)

  orbit_global.keystore.registerSignVerify(CONV_INIT_PREFIX, undefined, verifyConversationSignature(global_registry),
    message => {
      const eth_address = message.id.substr(-42) //hopefully the last 42 is the eth address
      onConverse(orbit_global, eth_address, message.payload)
    })
github redacademy / vue-ethereum-ipfs / src / OrbitDBPlugin.js View on Github external
ipfs.on('ready', async () => {
          // Create a database
          const orbitdb = new OrbitDB(ipfs)

          const db = await orbitdb.docstore('obligatron.test')
          resolve(db)
        })
      })
github fazo96 / ipfs-boards / src / orbitdb / index.js View on Github external
export async function start() {
  if (!window.ipfs) {
    window.ipfs = new IPFS({
      repo: 'ipfs-v6-boards-v0',
      EXPERIMENTAL: {
        pubsub: true
      }
    });
    await new Promise(resolve => {
      window.ipfs.on('ready', () => resolve())
    })
  }
  if (!window.orbitDb) {
    OrbitDB.addDatabaseType(BoardStore.type, BoardStore)
    window.orbitDb = new OrbitDB(window.ipfs)
  }
}
github UnsignedInt8 / Forever / src / p2p / FileSystem.ts View on Github external
constructor(ipfs: IPFS, dbAddress?: string) {
        super();
        this.ipfs = ipfs;
        this.address = dbAddress ? `${dbAddress}/disk` : 'disk';
        this.orbit = new OrbitDB(ipfs);
    }
github mistakia / record-app / src / core / db / service.js View on Github external
return new Promise((resolve, reject) => {

    if (peerId) {
      orbitdb = new OrbitDB(ipfs, './orbitdb', { peerId })
      return resolve(orbitdb.id)
    }

    PeerId.create((err, peer) => {
      if (err)
	return reject(err)

      const p = peer.toJSON()
      const peerId = p.id
      const key = ec.keyFromPrivate(privateKey || p.privKey)

      localStorage.setItem(peerId, JSON.stringify({
	publicKey: key.getPublic('hex'),
	privateKey: key.getPrivate('hex')
      }))

orbit-db

Distributed p2p database on IPFS

MIT
Latest version published 1 year ago

Package Health Score

59 / 100
Full package analysis