Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const IPFS = require('ipfs')
- const OrbitDB = require('orbit-db')
- const AccessController = require('orbit-db-access-controllers/src/access-controller-interface')
- let AccessControllers = require('orbit-db-access-controllers')
- class OtherAccessController extends AccessController {
- static get type () { return 'othertype' } // Return the type for this controller
- async canAppend(entry, identityProvider) {
- // logic to determine if entry can be added, for example:
- return true
- }
- async grant (access, identity) {} // Logic for granting access to identity
- }
- AccessControllers.addAccessController({ AccessController: OtherAccessController })
- // Create IPFS instance
- const ipfs1 = new IPFS({ repo: './ipfs1', EXPERIMENTAL: { pubsub: true } })
- ipfs1.on('ready', async () => {
- const orbitdb1 = await OrbitDB.createInstance(ipfs1, { directory: './orbitdb1', AccessControllers: AccessControllers })
- const options = {
- accessController: {
- type: 'othertype',
- write: [orbitdb1.identity.id]
- }
- }
- const db1 = await orbitdb1.keyvalue('first-database',options)
- console.log(db1.address.toString())
- await db1.put('name', 'test')
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement