``` import OrbitDB from 'orbit-db' import IPFS from 'ipfs' const ipfsOptions = { repo: './ipfs', relay: { enabled: true, hop: { enabled: true, active: true } }, EXPERIMENTAL: {pubsub: true }, Swarm: [ '/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star', '/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star', '/ip4/127.0.0.1/tcp/13579/wss/p2p-webrtc-star', '/ip4/127.0.0.1/tcp/4002/p2p/QmejbbSr9QvHfLbSTQaz5gBXqaUd17Z4tvi4F3xwNvGv9e', '/ip4/127.0.0.1/tcp/4003/ws/p2p/QmejbbSr9QvHfLbSTQaz5gBXqaUd17Z4tvi4F3xwNvGv9e', ], hop: { enabled: true, active: true } } // const docStoreOptions = {...defaultOptions,indexBy: 'hash',} export default class DBNode { async init(){ this.node = await IPFS.create(ipfsOptions) this.orbit = await OrbitDB.createInstance(this.node) this.otherDBs = {} } async load(){ const defaultOptions = { accessController: { write: [this.orbit.identity.id] }} const kvDB = await this.orbit.keyvalue('test-db', defaultOptions) kvDB.load() this.kvDB = kvDB const ipfsID = await this.node.id() const nodeAddress = kvDB.address.toString() console.log({ ipfsID, nodeAddress, orbitID: this.orbit.identity.id, }) return nodeAddress } async loadDB(name, conn) { console.log(this.node.types) const db = await this.orbit.open(conn) await db.load() this.otherDBs[name] = db db.events.on("replicated", () => console.log(`${name} replicated`)) } async cleanup() { this.kvDB && this.kvDB.close() for(const db of Object.values(this.otherDBs)){ db.close() } } async getPeerNodes(){ console.log(await this.node.bootstrap.list()) console.log(await this.node.swarm.peers()) } async connectPeer(address) { const protocol = "/p2p-circuit/ipfs/" try { this.node.swarm.connect(protocol + address) this.node.libp2p.on("peer:connect", () => console.log("peer connected")) } catch (error) { console.log("error connecting to peer", error) } } async getContent(cid){ const content = await this.node.dag.get(cid) console.log(content.value) } } ```