Hello everyone!
I need some help with libp2p
.
I have an IPFS node and its multiaddress so I can connect to it .
If I add a file via ipfs add foo
or ipfs pin
on this node, can I somehow use libp2p
or dht
to get a notification about this along with the CID (on other machine/IP)?
I tried to log some dht
info in the code below, but it logs nothing about dht
Thanks in advance!
const node = await Libp2p.create({
addresses: {
listen: ['/ip4/127.0.0.1/tcp/0'],
},
modules: {
transport: [TCP],
connEncryption: [NOISE],
streamMuxer: [Mplex],
peerDiscovery: [Bootstrap],
dht: kaddht,
},
config: {
peerDiscovery: {
bootstrap: {
interval: 60e3,
enabled: true,
list: ['NODE_MULTIADDR]
}
},
dht: {
enabled: true,
clientMode: false,
}
}
})
node.connectionManager.on('peer:connect', (connection) => {
console.log('Connection established to: ', connection.remotePeer.toB58String())
})
node.on('peer:discovery', (peerId) => {
console.log('Discovered: ', peerId.toB58String())
})
await node.start()
await node.handle(['/ipfs/kad/1.0.0'], async props => {
console.log(props)
})