mirror of https://github.com/nucypher/nucypher.git
Janitorial stuff
parent
5a7678337f
commit
2d2a7a7cde
|
@ -15,19 +15,6 @@
|
|||
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
"""
|
||||
This file is part of nucypher.
|
||||
nucypher is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
nucypher is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
import os
|
||||
from contextlib import suppress
|
||||
from functools import partial
|
||||
|
|
|
@ -19,10 +19,8 @@ from collections import namedtuple
|
|||
|
||||
import click
|
||||
import functools
|
||||
import os
|
||||
|
||||
from nucypher.blockchain.eth.constants import NUCYPHER_CONTRACT_NAMES
|
||||
from nucypher.blockchain.eth.networks import NetworksInventory
|
||||
from nucypher.cli.types import (
|
||||
EIP55_CHECKSUM_ADDRESS,
|
||||
EXISTING_READABLE_FILE,
|
||||
|
|
|
@ -338,9 +338,7 @@ class Learner:
|
|||
|
||||
self.done_seeding = True
|
||||
|
||||
if read_storage is True:
|
||||
nodes_restored_from_storage = self.read_nodes_from_storage()
|
||||
|
||||
nodes_restored_from_storage = self.read_nodes_from_storage() if read_storage else []
|
||||
discovered.extend(nodes_restored_from_storage)
|
||||
|
||||
if discovered and record_fleet_state:
|
||||
|
|
|
@ -23,54 +23,48 @@ import os
|
|||
|
||||
from typing import Set, Optional, Dict, List
|
||||
|
||||
from nucypher.blockchain.eth.registry import BaseContractRegistry
|
||||
from nucypher.cli.literature import (
|
||||
START_LOADING_SEEDNODES,
|
||||
NO_DOMAIN_PEERS,
|
||||
UNREADABLE_SEEDNODE_ADVISORY,
|
||||
SEEDNODE_NOT_STAKING_WARNING
|
||||
)
|
||||
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
||||
from nucypher.network.exceptions import NodeSeemsToBeDown
|
||||
from nucypher.network.middleware import RestMiddleware
|
||||
|
||||
|
||||
def load_static_nodes(domains: Set[str], filepath: Optional[str] = None) -> Dict[str, 'Ursula']:
|
||||
"""
|
||||
Non-invasive read teacher-uris from a JSON configuration file keyed by domain name.
|
||||
and return a filtered subset of domains and teacher URIs as a dict.
|
||||
"""
|
||||
# TODO: This module seems unused
|
||||
|
||||
if not filepath:
|
||||
filepath = os.path.join(DEFAULT_CONFIG_ROOT, 'static-nodes.json')
|
||||
try:
|
||||
with open(filepath, 'r') as file:
|
||||
static_nodes = json.load(file)
|
||||
except FileNotFoundError:
|
||||
return dict() # No static nodes file, No static nodes.
|
||||
except JSONDecodeError:
|
||||
raise RuntimeError(f"Static nodes file '{filepath}' contains invalid JSON.")
|
||||
filtered_static_nodes = {domain: uris for domain, uris in static_nodes.items() if domain in domains}
|
||||
return filtered_static_nodes
|
||||
|
||||
|
||||
def aggregate_seednode_uris(domains: set, highest_priority: Optional[List[str]] = None) -> List[str]:
|
||||
|
||||
# Read from the disk
|
||||
static_nodes = load_static_nodes(domains=domains)
|
||||
|
||||
# Priority 1 - URI passed via --teacher
|
||||
uris = highest_priority or list()
|
||||
for domain in domains:
|
||||
|
||||
# 2 - Static nodes from JSON file
|
||||
domain_static_nodes = static_nodes.get(domain)
|
||||
if domain_static_nodes:
|
||||
uris.extend(domain_static_nodes)
|
||||
|
||||
# 3 - Hardcoded teachers from module
|
||||
hardcoded_uris = TEACHER_NODES.get(domain)
|
||||
if hardcoded_uris:
|
||||
uris.extend(hardcoded_uris)
|
||||
|
||||
return uris
|
||||
# def load_static_nodes(domains: Set[str], filepath: Optional[str] = None) -> Dict[str, 'Ursula']:
|
||||
# """
|
||||
# Non-invasive read teacher-uris from a JSON configuration file keyed by domain name.
|
||||
# and return a filtered subset of domains and teacher URIs as a dict.
|
||||
# """
|
||||
#
|
||||
# if not filepath:
|
||||
# filepath = os.path.join(DEFAULT_CONFIG_ROOT, 'static-nodes.json')
|
||||
# try:
|
||||
# with open(filepath, 'r') as file:
|
||||
# static_nodes = json.load(file)
|
||||
# except FileNotFoundError:
|
||||
# return dict() # No static nodes file, No static nodes.
|
||||
# except JSONDecodeError:
|
||||
# raise RuntimeError(f"Static nodes file '{filepath}' contains invalid JSON.")
|
||||
# filtered_static_nodes = {domain: uris for domain, uris in static_nodes.items() if domain in domains}
|
||||
# return filtered_static_nodes
|
||||
#
|
||||
#
|
||||
#
|
||||
# def aggregate_seednode_uris(domains: set, highest_priority: Optional[List[str]] = None) -> List[str]:
|
||||
#
|
||||
# # Read from the disk
|
||||
# static_nodes = load_static_nodes(domains=domains)
|
||||
#
|
||||
# # Priority 1 - URI passed via --teacher
|
||||
# uris = highest_priority or list()
|
||||
# for domain in domains:
|
||||
#
|
||||
# # 2 - Static nodes from JSON file
|
||||
# domain_static_nodes = static_nodes.get(domain)
|
||||
# if domain_static_nodes:
|
||||
# uris.extend(domain_static_nodes)
|
||||
#
|
||||
# # 3 - Hardcoded teachers from module
|
||||
# hardcoded_uris = TEACHER_NODES.get(domain)
|
||||
# if hardcoded_uris:
|
||||
# uris.extend(hardcoded_uris)
|
||||
#
|
||||
# return uris
|
||||
|
|
|
@ -97,6 +97,7 @@ def test_federated_development_character_configurations(character, configuration
|
|||
alice.disenchant()
|
||||
|
||||
|
||||
# TODO: This test is unnecessarily slow due to the blockchain configurations. Perhaps we should mock them -- See #2230
|
||||
@pytest.mark.parametrize('configuration_class', all_configurations)
|
||||
def test_default_character_configuration_preservation(configuration_class, testerchain, test_registry_source_manager):
|
||||
|
||||
|
|
Loading…
Reference in New Issue