我正在使用 js-ipfs 并想使用 IPFS 的发布功能。下面给出的是代码
let result = await ipfs.add("hello");
const ipns_hash = await ipfs.name.publish('/ipfs/'+result.cid)
console.log(ipns_hash)
我参考了官方的 js-ipfs CORE APIs 文档来实现上面的发布命令。
这是我运行上述命令时遇到的错误,
file:///home/shubh/Desktop/BTech/Project/ipfstrail/node_modules/ipfs-http-client/esm/src/lib/core.js:75
let error = new HTTP.HTTPError(response);
^
**HTTPError: ipns record for f5uxa3ttf4acicabciqiyeamon3gnuvgikdcknbuwyhicyeolhegmomtrvd5fpy53oulfvy could not be stored in the routing**
at Object.errorHandler [as handleError] (file:///home/shubh/Desktop/BTech/Project/ipfstrail/node_modules/ipfs-http-client/esm/src/lib/core.js:75:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Client.fetch (/home/shubh/Desktop/BTech/Project/ipfstrail/node_modules/ipfs-utils/src/http.js:145:9)
at async Object.publish (file:///home/shubh/Desktop/BTech/Project/ipfstrail/node_modules/ipfs-http-client/esm/src/name/publish.js:6:17)
at async saveText (file:///home/shubh/Desktop/BTech/Project/ipfstrail/app.js:156:23) {
response: Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: PassThrough {
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: [],
flowing: true,
ended: true,
endEmitted: true,
reading: false,
constructed: true,
sync: false,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
destroyed: true,
errored: null,
closed: true,
closeEmitted: true,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: true,
decoder: null,
encoding: null,
[Symbol(kPaused)]: false
},
_events: [Object: null prototype] {
prefinish: [Function: prefinish],
error: [ [Function (anonymous)], [Function (anonymous)] ],
data: [Function (anonymous)],
end: [Function (anonymous)]
},
_eventsCount: 4,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: true,
needDrain: false,
ending: true,
ended: true,
finished: true,
destroyed: true,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 0,
constructed: true,
prefinished: true,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
errored: null,
closed: true,
closeEmitted: true,
[Symbol(kOnFinished)]: []
},
allowHalfOpen: true,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null
},
disturbed: true,
error: null
},
[Symbol(Response internals)]: {
url: 'http://localhost:5002/api/v0/name/publish?arg=%2Fipfs%2FQmWfVY9y3xjsixTgbd9AorQxH7VtMpzfx2HaWtsoUYecaX',
status: 500,
statusText: 'Internal Server Error',
headers: Headers {
[Symbol(map)]: [Object: null prototype] {
'content-type': [ 'application/json; charset=utf-8' ],
'cache-control': [ 'no-cache' ],
'content-length': [ '160' ],
date: [ 'Tue, 22 Feb 2022 17:42:43 GMT' ],
connection: [ 'keep-alive' ],
'keep-alive': [ 'timeout=5' ]
}
},
counter: 0
}
}
}
有什么解决方案吗?
注意:我正在开发 ^55.0.0 版本的 ipfs-http-client 模块