mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-08-28 18:14:19 -05:00
* use chia_rs directly for sized ints * Update data_layer_rpc_api.py
26 lines
716 B
Python
26 lines
716 B
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Iterable
|
|
|
|
from chia_rs.sized_ints import uint16
|
|
|
|
from chia.protocols.shared_protocol import 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[Capability] = set()
|
|
for value, state in values:
|
|
if state != "1":
|
|
continue
|
|
|
|
try:
|
|
filtered.add(Capability(value))
|
|
except ValueError:
|
|
pass
|
|
|
|
# TODO: consider changing all uses to sets instead of lists
|
|
return list(filtered)
|