@@ -593,9 +593,9 @@ export class Libp2pService extends EventEmitter implements OnModuleDestroy {
593593 this . libp2pInstance . addEventListener ( 'peer:connect' , async event => {
594594 const remotePeerId = event . detail . toString ( )
595595 const connection = this . libp2pInstance ?. getConnections ( event . detail )
596+ const remoteAddr = connection ?. [ 0 ] ?. remoteAddr ?. toString ( )
596597 if ( this . state === Libp2pState . Paused ) {
597598 this . logger . warn ( `Received connection from ${ remotePeerId } while paused, hanging up` )
598- const remoteAddr = connection ?. [ 0 ] ?. remoteAddr ?. toString ( )
599599 if ( remoteAddr ) {
600600 await this . hangUpPeer ( remoteAddr )
601601 } else if ( this . libp2pInstance ) {
@@ -616,6 +616,7 @@ export class Libp2pService extends EventEmitter implements OnModuleDestroy {
616616 const peerStats : Record < string , NetworkStats > = { }
617617 peerStats [ remotePeerId ] = {
618618 ...( peerPrevStats ?? { } ) ,
619+ peerId : remotePeerId ,
619620 connectionTime : peerPrevStats ?. connectionTime ?? 0 ,
620621 lastSeen : DateTime . utc ( ) . valueOf ( ) ,
621622 } as NetworkStats
@@ -624,7 +625,7 @@ export class Libp2pService extends EventEmitter implements OnModuleDestroy {
624625 if ( connection ) {
625626 this . connectedPeers . set ( remotePeerId , {
626627 peerId : remotePeerId ,
627- address : peerStats [ remotePeerId ] . address ,
628+ address : peerStats [ remotePeerId ] . address || remoteAddr ,
628629 connectedAtSeconds : DateTime . utc ( ) . toSeconds ( ) ,
629630 } as Libp2pConnectedPeer )
630631 }
0 commit comments