How to use orbit-db-io - 3 common examples

To help you get started, we’ve selected a few orbit-db-io 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 ambientsprotocol / ambc / src / index.js View on Github external
result = ambient
      break
    case 'ir':
      result = js.irParser.parse(ambient)
      break
    default:
      result = js.parse(ambient)
      break
  }

  // --display flag
  // -o option
  if (argv.display) return process.stdout.write(result)
  if (argv.o) return fs.writeFileSync(argv.o, result)

  const hash = await io.write(ipfs, 'dag-cbor', result)
  return hash
}
github orbitdb / orbit-db / src / db-manifest.js View on Github external
const createDBManifest = async (ipfs, name, type, accessControllerAddress, options) => {
  const manifest = Object.assign({
    name: name,
    type: type,
    accessController: (path.posix || path).join('/ipfs', accessControllerAddress)
  },
  // meta field is only added to manifest if options.meta is defined
  options.meta !== undefined ? { meta: options.meta } : {}
  )

  return io.write(ipfs, options.format || 'dag-cbor', manifest, options)
}
github orbitdb / orbit-db-store / src / Store.js View on Github external
if (!head) {
        console.warn("Warning: Given input entry was 'null'.")
        return Promise.resolve(null)
      }

      const identityProvider = this.identity.provider
      if (!identityProvider) throw new Error('Identity-provider is required, cannot verify entry')

      const canAppend = await this.access.canAppend(head, identityProvider)
      if (!canAppend) {
        console.warn('Warning: Given input entry is not allowed in this log and was discarded (no write access).')
        return Promise.resolve(null)
      }

      const logEntry = Entry.toEntry(head)
      const hash = await io.write(this._ipfs, Entry.getWriteFormat(logEntry), logEntry, { links: Entry.IPLD_LINKS, onlyHash: true })

      if (hash !== head.hash) {
        console.warn('"WARNING! Head hash didn\'t match the contents')
      }

      return head
    }

orbit-db-io

IO helper module for orbit-db

MIT
Latest version published 1 year ago

Package Health Score

51 / 100
Full package analysis

Popular orbit-db-io functions