File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
src/protocol/libp2p/kademlia Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -268,13 +268,15 @@ impl MemoryStore {
268
268
return ;
269
269
} ;
270
270
271
- let drop_key = match self . provider_keys . get_mut ( & key) {
272
- None => {
271
+ match self . provider_keys . entry ( key. clone ( ) ) {
272
+ Entry :: Vacant ( _ ) => {
273
273
tracing:: error!( ?key, "local provider key not found during removal" , ) ;
274
274
debug_assert ! ( false ) ;
275
275
return ;
276
276
}
277
- Some ( providers) => {
277
+ Entry :: Occupied ( mut entry) => {
278
+ let providers = entry. get_mut ( ) ;
279
+
278
280
// Providers are sorted by distance.
279
281
let local_provider_distance = KademliaKey :: from ( self . local_peer_id . clone ( ) )
280
282
. distance ( & KademliaKey :: new ( key. clone ( ) ) ) ;
@@ -292,13 +294,11 @@ impl MemoryStore {
292
294
}
293
295
}
294
296
295
- providers. is_empty ( )
297
+ if providers. is_empty ( ) {
298
+ entry. remove ( ) ;
299
+ }
296
300
}
297
301
} ;
298
-
299
- if drop_key {
300
- self . provider_keys . remove ( & key) ;
301
- }
302
302
}
303
303
304
304
/// Poll next action from the store.
You can’t perform that action at this time.
0 commit comments