node.js - nodejs中的Orbitdb + IPFS
问题描述
我正在尝试将 orbit-db 与 IPFS 一起使用,并且正在阅读 OrbitDB 的官方文档。ATM,我只是想创建一个数据库(特别是键值存储),我现在有以下代码
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
createDb = async() => {
try {
const ipfsOptions = {
config: {
my-config-options
},
EXPERIMENTAL: {
pubsub: true
}
}
const ipfs = await IPFS.create(ipfsOptions)
const orbitdb = await OrbitDB.createInstance(ipfs)
const db = await orbitdb.create('test', 'keyvalue', {
overwrite: false,
replicate: true,
accessController: {
admin: ['*'],
write: ['*']
}
})
console.log(db)
await db.put('hello', { name: 'world' })
console.log(db.all)
} catch (error) {
console.trace(error)
}
}
但无论我尝试什么,我都会遇到同样的错误
Trace: Error: Could not append entry, key "..." is not allowed to write to the log
所以任何帮助将不胜感激。如果缺少任何信息,也请发表评论,我会根据要求添加它
解决方案
我认为您的accessController
. 该admin
属性的存在表明您要使用这样的orbitdb
类型:
accessController: {
type: 'orbitdb',
admin: ['*'],
write: ['*']
}
否则,如果您希望使用默认ipfs
类型,请删除 admin 属性,如下所示:
accessController: {
type: 'ipfs',
write: ['*']
}
推荐阅读
- excel - Unable to grab a portion of text from a website using post http requests
- pandas - CSV pandas 阅读器分隔符不起作用
- python - pybrain install in env but No module named 'pybrain'
- python-3.x - Defining in-line comments in Python
- ios - iOS - Change "Test Details" of test flight build
- android - 从 build.gradle 迁移到 build.gradle.kts 时遇到一些代码片段问题
- php - php for 循环中的 for 循环
- javascript - 使用路由器时反应页面不会自动刷新
- google-cloud-platform - Kubernetes Ingress Controller GPC GKE 无法访问站点
- python - discrod.py Text channel history to HTML file