From 58302968d9d57388b06b590446c8364babc84885 Mon Sep 17 00:00:00 2001 From: dustinface <35775977+xdustinface@users.noreply.github.com> Date: Tue, 18 Apr 2023 23:28:00 +0700 Subject: [PATCH] server: Try to convert in `known_active_capabilities` (#15046) --- chia/server/capabilities.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/chia/server/capabilities.py b/chia/server/capabilities.py index 45aa46a4b40e9..cdb9acbb80d75 100644 --- a/chia/server/capabilities.py +++ b/chia/server/capabilities.py @@ -5,22 +5,20 @@ from typing import Iterable, List, Set, Tuple from chia.protocols.shared_protocol import Capability from chia.util.ints import uint16 -_capability_values = {int(capability) for capability in Capability} - def known_active_capabilities(values: Iterable[Tuple[uint16, str]]) -> List[Capability]: # NOTE: order is not guaranteed # TODO: what if there's a claim for both supporting and not? # presently it considers it supported - filtered: Set[uint16] = set() + filtered: Set[Capability] = set() for value, state in values: if state != "1": continue - if value not in _capability_values: - continue - - filtered.add(value) + try: + filtered.add(Capability(value)) + except ValueError: + pass # TODO: consider changing all uses to sets instead of lists - return [Capability(value) for value in filtered] + return list(filtered)