Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit 86b3c67

Browse files
committed
fix: move igroup deletion after reply processing
1 parent 2f08f36 commit 86b3c67

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

mix/mix_protocol.nim

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type
2020
members: HashSet[I]
2121

2222
ConnCreds = object
23-
group: IGroup
23+
igroup: IGroup
2424
incoming: AsyncQueue[seq[byte]]
2525
surbSecret: secret
2626
surbKey: key
@@ -238,17 +238,17 @@ proc handleMixNodeConnection(
238238

239239
let connCred = mixProto.connCreds[processedSP.id]
240240

241-
# Deleting all other SURBs associated to this
242-
for id in connCred.group.members:
243-
mixProto.connCreds.del(id)
244-
245241
let reply = processReply(
246242
connCred.surbKey, connCred.surbSecret, processedSP.delta_prime
247243
).valueOr:
248244
error "could not process reply", id = processedSP.id
249245
mix_messages_error.inc(labelValues = ["Reply", "INVALID_CREDS"])
250246
return
251247

248+
# Deleting all other SURBs associated to this
249+
for id in connCred.igroup.members:
250+
mixProto.connCreds.del(id)
251+
252252
let msgChunk = MessageChunk.deserialize(reply).valueOr:
253253
error "Deserialization failed", err = error
254254
mix_messages_error.inc(labelValues = ["Reply", "INVALID_SPHINX"])
@@ -366,8 +366,8 @@ proc buildSurbs(
366366
exitPeerId: PeerId,
367367
): Result[seq[SURB], string] =
368368
var response: seq[SURB]
369-
var group = IGroup(members: initHashSet[I]())
370-
369+
var igroup = IGroup(members: initHashSet[I]())
370+
371371
for _ in uint8(0) ..< numSurbs:
372372
var
373373
id: I
@@ -432,8 +432,13 @@ proc buildSurbs(
432432
let surb = createSURB(publicKeys, delay, hops, id).valueOr:
433433
return err(error)
434434

435-
group.members.incl(id)
436-
mixProto.connCreds[id] = ConnCreds(group: group, surbSecret: surb.secret.get(), surbKey: surb.key, incoming: incoming)
435+
igroup.members.incl(id)
436+
mixProto.connCreds[id] = ConnCreds(
437+
igroup: igroup,
438+
surbSecret: surb.secret.get(),
439+
surbKey: surb.key,
440+
incoming: incoming,
441+
)
437442
response.add(surb)
438443

439444
return ok(response)

0 commit comments

Comments
 (0)