mirror of https://github.com/nucypher/nucypher.git
type hinting and removal of misleading comments.
parent
de8d96e8ea
commit
7246e10f84
|
@ -1,15 +1,13 @@
|
|||
import base64
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
from timeit import default_timer as timer
|
||||
|
||||
import maya
|
||||
import msgpack
|
||||
import os
|
||||
import shutil
|
||||
from nucypher_core import EncryptedTreasureMap, MessageKit
|
||||
from nucypher_core.umbral import PublicKey
|
||||
from timeit import default_timer as timer
|
||||
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.characters.lawful import Bob
|
||||
from nucypher.crypto.keypairs import DecryptingKeypair, SigningKeypair
|
||||
|
|
|
@ -248,22 +248,14 @@ class Operator(BaseActor):
|
|||
) -> DefaultDict[int, Set[HTTPProvider]]:
|
||||
"""Multi-provider support"""
|
||||
|
||||
# If condition_blockchain_endpoints is None the node operator
|
||||
# did not configure any additional condition providers.
|
||||
condition_blockchain_endpoints = condition_blockchain_endpoints or dict()
|
||||
|
||||
# These are the chains that the Operator will connect to for conditions evaluation (read-only).
|
||||
condition_providers = defaultdict(set)
|
||||
|
||||
# Now, add any additional providers that were passed in.
|
||||
for (
|
||||
chain_id,
|
||||
condition_blockchain_endpoints,
|
||||
) in condition_blockchain_endpoints.items():
|
||||
if not self._is_permitted_condition_chain(chain_id):
|
||||
# this is a safety check to prevent the Operator from connecting to
|
||||
# chains that are not supported by ursulas on the network;
|
||||
# Prevents the Ursula/Operator from starting up if this happens.
|
||||
raise NotImplementedError(
|
||||
f"Chain ID {chain_id} is not supported for condition evaluation by this Operator."
|
||||
)
|
||||
|
@ -272,10 +264,8 @@ class Operator(BaseActor):
|
|||
for uri in condition_blockchain_endpoints:
|
||||
provider = self._make_condition_provider(uri)
|
||||
providers.add(provider)
|
||||
|
||||
condition_providers[int(chain_id)] = providers
|
||||
|
||||
# Log the chains that the Operator is connected to.
|
||||
humanized_chain_ids = ", ".join(
|
||||
_CONDITION_CHAINS[chain_id] for chain_id in condition_providers
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from cytoolz.functoolz import memoize
|
||||
from enum import Enum
|
||||
from typing import NamedTuple, Dict
|
||||
from typing import NamedTuple, Dict, Any
|
||||
|
||||
|
||||
class UnrecognizedTacoDomain(Exception):
|
||||
|
@ -30,25 +30,25 @@ class TACoDomain:
|
|||
self.eth_chain = eth_chain
|
||||
self.polygon_chain = polygon_chain
|
||||
|
||||
def __repr__(self):
|
||||
def __repr__(self) -> str:
|
||||
return f"<TACoDomain {self.name}>"
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
||||
def __hash__(self):
|
||||
def __hash__(self) -> int:
|
||||
return hash(self.name)
|
||||
|
||||
def __bytes__(self):
|
||||
def __bytes__(self) -> bytes:
|
||||
return self.name.encode()
|
||||
|
||||
def __eq__(self, other):
|
||||
def __eq__(self, other: Any) -> bool:
|
||||
try:
|
||||
return self.name == other.name
|
||||
except AttributeError:
|
||||
raise TypeError(f"Cannot compare TACoDomain to {type(other)}")
|
||||
|
||||
def __bool__(self):
|
||||
def __bool__(self) -> bool:
|
||||
return True
|
||||
|
||||
@property
|
||||
|
@ -82,7 +82,7 @@ SUPPORTED_DOMAINS: Dict[str, TACoDomain] = {domain.name: domain for domain in (M
|
|||
|
||||
|
||||
@memoize
|
||||
def get_domain(d: str) -> TACoDomain:
|
||||
def get_domain(d: Any) -> TACoDomain:
|
||||
if not isinstance(d, str):
|
||||
raise TypeError(f"domain must be a string, not {type(d)}")
|
||||
for name, domain in SUPPORTED_DOMAINS.items():
|
||||
|
|
Loading…
Reference in New Issue