use choices

This commit is contained in:
Youngjoon Lee 2024-07-11 17:00:11 +09:00
parent e1abc44592
commit e558ba4e6d
No known key found for this signature in database
GPG Key ID: B4253AFBA618BF4D

View File

@ -51,9 +51,9 @@ class MixMembership:
def generate_route(self, length: int) -> list[NodeInfo]:
"""
Generate a mix route for a Sphinx packet.
Choose `length` nodes with replacement as a mix route.
"""
return [random.choice(self.nodes) for _ in range(length)]
return random.choices(self.nodes, k=length)
@dataclass