-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Transfering DAG object between two computers #881
Comments
That's a strange behavior. I see you are using async/await, I assume you have wrapped the API to expose that? Check the bitswap wantlist. |
This code I run on first laptop: const IPFS = require('ipfs')
const DAGOptions = { format: 'dag-cbor', hashAlg: 'sha2-256' }
const node = new IPFS()
node.on('ready', async () => {
const cid = await node.dag.put({ a: 'b' }, DAGOptions)
console.log(cid.toBaseEncodedString())
const { value } = await node.dag.get(cid)
console.log(value)
let knownPeers = []
setInterval(async () => {
const addrs = await node.swarm.addrs()
const newPeers = []
addrs.forEach((addr) => {
const id = addr.id.toB58String()
if (!knownPeers.includes(id)) {
newPeers.push(id)
}
})
if (newPeers.length > 0) {
console.log(newPeers)
knownPeers = [...knownPeers, ...newPeers]
}
}, 1000)
}) console output
This code I run on second laptop: const IPFS = require('ipfs')
const node = new IPFS()
node.on('ready', async () => {
node.dag.get('zdpuAw6c3ViCx5A7K4nukvmxh3ZtTHnyknmxCLQmGa6JDmDMn', (err, result) => {
if (err) {
console.log(err)
} else {
console.log(result.value)
}
})
console.log(node.bitswap.wantlist())
setTimeout(() => {
console.log(node.bitswap.wantlist())
}, 1000)
let knownPeers = []
setInterval(async () => {
const addrs = await node.swarm.addrs()
const newPeers = []
addrs.forEach((addr) => {
const id = addr.id.toB58String()
if (!knownPeers.includes(id)) {
newPeers.push(id)
}
})
if (newPeers.length > 0) {
console.log('NEW PEERS =>')
console.log(newPeers)
knownPeers = [...knownPeers, ...newPeers]
}
}, 1000)
}) console output
Get request appears in wantlist not immediately, I asume it's okay? By the way, any ideas where those first 9 nodes came from? |
Are you use that both of your laptops are connected? The first 9 nodes are the bootstrappers nodes. |
@diasdavid
|
@negamaxi any update on this issue? Still seeing an issue? |
@diasdavid I'll check once I get a new laptop. |
Hi @negamaxi, were you able to check this? |
Hi, still not. Faced another issue #1016. |
@negamaxi still an issue? Would love to make sure this is fixed if there is indeed a real problem. Could you add a failing test to our bitswap batch? |
@diasdavid as for now it's not an issue for me as we moved to go-ipfs + js-ipfs-api with custom DAG implementation that works as expected. Anyway just tried with js-ipfs 0.27.7: // pc-publisher
node.on('ready', async () => {
await node.dag.put({ a: 'b' }, dagParams)
}) // pc-receiver
node.on('ready', () => {
setInterval(async () => {
try {
const value = await node.dag.get('zdpuAw6c3ViCx5A7K4nukvmxh3ZtTHnyknmxCLQmGa6JDmDMn')
console.log(value)
} catch (e) {
console.error(e)
}
}, 1000)
}) And still no luck, although publisher id appears in receivers nodelist in about 5 seconds. I'm not too experienced in writing tests but will be glad to take a try. Just point me which repo I should contribute to. |
@negamaxi exactly. |
@diasdavid as ipfsd-ctl relies on js-ipfs-api that currently missing dag interface I wasn't able to use |
Excellent @negamaxi. Solved then :) |
Anything that isn't a string needs to be passed with `--json`. fixes ipfs#881 Depends on: * [x] ipfs-inactive/interface-js-ipfs-core#470 License: MIT Signed-off-by: Alan Shaw <[email protected]>
I have two laptops, both running js-ipfs nodes. On the first one I put javascript object with:
Then I convert cid
toBaseEncodedString()
, send via messenger to my second laptop and trying to get content with:...but
console.log
never happens and no errors. Multiaddr of my first laptop appears innode.swarm.addrs()
of the second one like that[ <Multiaddr 04c0a86406060fa2 - /ip4/192.168.100.6/tcp/4002> ]
what I believe means both nodes see each other. Any advice on how to make it work? Thanks!
The text was updated successfully, but these errors were encountered: