@@ -229,7 +229,7 @@ class CorestoreNetworker extends Nanoresource {
229
229
if ( this . swarm && this . swarm . destroyed ) return Promise . resolve ( )
230
230
231
231
const id = Symbol ( 'id' )
232
- const prom = this . _configure ( discoveryKey , opts , id )
232
+ const prom = this . _configure ( discoveryKey , opts , id , false )
233
233
const keyString = toString ( discoveryKey )
234
234
const prev = this . _configurations . get ( keyString ) || { lookup : false , announce : false , id : null }
235
235
@@ -252,23 +252,25 @@ class CorestoreNetworker extends Nanoresource {
252
252
const conf = this . _configurations . get ( keyString )
253
253
254
254
if ( ! conf || conf . id !== prom . configureId ) return
255
- return this . _configure ( discoveryKey , prom . previous , prom . previous . id )
255
+ return this . _configure ( discoveryKey , prom . previous , prom . previous . id , true )
256
256
}
257
257
258
- async _configure ( discoveryKey , opts = { } , id ) {
258
+ async _configure ( discoveryKey , opts , id , isUnconfigure ) {
259
259
const config = {
260
260
announce : opts . announce !== false ,
261
261
lookup : opts . lookup !== false
262
262
}
263
263
opts = { ...opts , ...config , id }
264
264
265
265
const keyString = toString ( discoveryKey )
266
+ const current = this . _configurations . get ( keyString )
266
267
267
268
if ( id ) this . _configurations . set ( keyString , opts )
268
269
else this . _configurations . delete ( keyString )
269
270
270
271
const joining = config . announce || config . lookup
271
272
if ( joining ) {
273
+ if ( isUnconfigure && current && current . lookup === config . lookup && current . announce === config . announce ) return
272
274
return this . _join ( discoveryKey , opts )
273
275
} else {
274
276
return this . _leave ( discoveryKey )
0 commit comments