Commit 59ea9c3 1 parent 300936f commit 59ea9c3 Copy full SHA for 59ea9c3
File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 42
42
"dependencies" : {
43
43
"libp2p-ping" : " ~0.3.2" ,
44
44
"libp2p-swarm" : " ~0.28.0" ,
45
+ "mafmt" : " ^2.1.8" ,
45
46
"multiaddr" : " ^2.3.0" ,
46
47
"peer-book" : " ~0.3.2" ,
47
48
"peer-id" : " ~0.8.5" ,
54
55
" greenkeeperio-bot <support@greenkeeper.io>" ,
55
56
" mayerwin <mayerwin@users.noreply.github.com>"
56
57
]
57
- }
58
+ }
Original file line number Diff line number Diff line change 3
3
const Swarm = require ( 'libp2p-swarm' )
4
4
const PeerId = require ( 'peer-id' )
5
5
const PeerInfo = require ( 'peer-info' )
6
+ const mafmt = require ( 'mafmt' )
6
7
const PeerBook = require ( 'peer-book' )
7
8
const multiaddr = require ( 'multiaddr' )
8
9
const EventEmitter = require ( 'events' ) . EventEmitter
@@ -47,6 +48,8 @@ class Node extends EventEmitter {
47
48
48
49
this . swarm . on ( 'peer-mux-closed' , ( peerInfo ) => {
49
50
this . emit ( 'peer:disconnect' , peerInfo )
51
+ // TODO remove this line
52
+ this . peerBook . removeByB58String ( peerInfo . id . toB58String ( ) )
50
53
} )
51
54
}
52
55
@@ -104,6 +107,13 @@ class Node extends EventEmitter {
104
107
}
105
108
} )
106
109
110
+ // so that we can have webrtc-star addrs without adding manually the id
111
+ this . peerInfo . multiaddrs = this . peerInfo . multiaddrs . map ( ( ma ) => {
112
+ if ( ! mafmt . IPFS . matches ( ma ) ) {
113
+ ma = ma . encapsulate ( '/ipfs/' + this . peerInfo . id . toB58String ( ) )
114
+ }
115
+ } )
116
+
107
117
this . swarm . listen ( ( err ) => {
108
118
if ( err ) {
109
119
return callback ( err )
You can’t perform that action at this time.
0 commit comments