Skip to content

Commit

Permalink
fix: add additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Nov 2, 2023
1 parent 653c74b commit 94d21cb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/libp2p-daemon-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ export class Server implements Libp2pServer {
const addrs = request.connect.addrs.map((a) => multiaddr(a))
const peerId = peerIdFromBytes(peer)

log('connect - adding multiaddrs %a to peer %p', addrs, peerId)
await this.libp2p.peerStore.merge(peerId, {
multiaddrs: addrs
})

log('connect - dial %p', peerId)
return this.libp2p.dial(peerId)
}

Expand All @@ -102,7 +105,11 @@ export class Server implements Libp2pServer {

const { peer, proto } = request.streamOpen
const peerId = peerIdFromBytes(peer)

log('openStream - dial %p', peerId)
const connection = await this.libp2p.dial(peerId)

log('openStream - open stream for protocol %s', proto)
const stream = await connection.newStream(proto, {
runOnTransientConnection: true
})
Expand Down Expand Up @@ -131,6 +138,7 @@ export class Server implements Libp2pServer {
const addr = multiaddr(request.streamHandler.addr)
let conn: MultiaddrConnection

log('registerStreamHandler - handle %s', protocols)
await this.libp2p.handle(protocols, ({ connection, stream }) => {
Promise.resolve()
.then(async () => {
Expand Down

0 comments on commit 94d21cb

Please sign in to comment.