mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-12-01 03:18:11 +03:00
server: Try to convert in known_active_capabilities
(#15046)
This commit is contained in:
parent
e5b94d34a0
commit
58302968d9
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user