@@ -36,7 +36,7 @@ class ConnectionManager {
36
36
constructor ( libp2p , options ) {
37
37
this . _libp2p = libp2p
38
38
this . _registrar = libp2p . registrar
39
- this . _peerId = libp2p . peerInfo . id . toString ( )
39
+ this . _peerId = libp2p . peerInfo . id . toB58String ( )
40
40
this . _options = mergeOptions . call ( { ignoreUndefined : true } , defaultOptions , options )
41
41
assert (
42
42
this . _options . maxConnections > this . _options . minConnections ,
@@ -91,8 +91,8 @@ class ConnectionManager {
91
91
if ( value < 0 || value > 1 ) {
92
92
throw new Error ( 'value should be a number between 0 and 1' )
93
93
}
94
- if ( peerId . toString ) {
95
- peerId = peerId . toString ( )
94
+ if ( peerId . toB58String ) {
95
+ peerId = peerId . toB58String ( )
96
96
}
97
97
this . _peerValues . set ( peerId , value )
98
98
}
@@ -119,7 +119,7 @@ class ConnectionManager {
119
119
* @param {Connection } connection
120
120
*/
121
121
onConnect ( connection ) {
122
- const peerId = connection . remotePeer . toString ( )
122
+ const peerId = connection . remotePeer . toB58String ( )
123
123
this . _connections . set ( connection . id , connection )
124
124
if ( ! this . _peerValues . has ( peerId ) ) {
125
125
this . _peerValues . set ( peerId , this . _options . defaultPeerValue )
@@ -133,7 +133,7 @@ class ConnectionManager {
133
133
*/
134
134
onDisconnect ( connection ) {
135
135
this . _connections . delete ( connection . id )
136
- this . _peerValues . delete ( connection . remotePeer . toString ( ) )
136
+ this . _peerValues . delete ( connection . remotePeer . toB58String ( ) )
137
137
}
138
138
139
139
/**
@@ -175,7 +175,7 @@ class ConnectionManager {
175
175
debug ( '%s: lowest value peer is %s' , this . _peerId , peerId )
176
176
debug ( '%s: closing a connection to %j' , this . _peerId , peerId )
177
177
for ( const connection of this . _connections . values ( ) ) {
178
- if ( connection . remotePeer . toString ( ) === peerId ) {
178
+ if ( connection . remotePeer . toB58String ( ) === peerId ) {
179
179
connection . close ( )
180
180
break
181
181
}
0 commit comments