mirror of https://github.com/nucypher/nucypher.git
Cleanup blockchain defaults and constants integration
parent
7e04dd117b
commit
dadb49c4ce
|
@ -80,12 +80,10 @@ class Miner(NucypherTokenActor):
|
|||
class MinerError(NucypherTokenActor.ActorError):
|
||||
pass
|
||||
|
||||
def __init__(self,
|
||||
is_me=True,
|
||||
miner_agent: MinerAgent = None,
|
||||
*args, **kwargs) -> None:
|
||||
|
||||
miner_agent = miner_agent if miner_agent is not None else MinerAgent()
|
||||
def __init__(self, miner_agent: MinerAgent, is_me=True, *args, **kwargs) -> None:
|
||||
if miner_agent is None:
|
||||
token_agent = NucypherTokenAgent()
|
||||
miner_agent = MinerAgent(token_agent=token_agent)
|
||||
super().__init__(token_agent=miner_agent.token_agent, *args, **kwargs)
|
||||
|
||||
# Extrapolate dependencies
|
||||
|
@ -98,6 +96,7 @@ class Miner(NucypherTokenActor):
|
|||
#
|
||||
# Staking
|
||||
#
|
||||
|
||||
@property
|
||||
def is_staking(self):
|
||||
"""Checks if this Miner currently has locked tokens."""
|
||||
|
|
|
@ -35,9 +35,7 @@ class EthereumContractAgent(ABC):
|
|||
contract: Contract = None
|
||||
) -> None:
|
||||
|
||||
if blockchain is None:
|
||||
blockchain = Blockchain.connect()
|
||||
self.blockchain = blockchain
|
||||
self.blockchain = blockchain or Blockchain.connect()
|
||||
|
||||
if registry_filepath is not None:
|
||||
# TODO: Warn on override/ do this elsewhere?
|
||||
|
@ -100,23 +98,13 @@ class MinerAgent(EthereumContractAgent):
|
|||
|
||||
principal_contract_name = "MinersEscrow"
|
||||
_upgradeable = True
|
||||
__instance = None # TODO: constants.NO_CONTRACT_AVAILABLE
|
||||
__instance = NO_CONTRACT_AVAILABLE
|
||||
|
||||
class NotEnoughMiners(Exception):
|
||||
pass
|
||||
|
||||
def __init__(self,
|
||||
token_agent: NucypherTokenAgent = None,
|
||||
registry_filepath: str = None,
|
||||
*args, **kwargs
|
||||
) -> None:
|
||||
|
||||
token_agent = token_agent if token_agent is not None else NucypherTokenAgent(registry_filepath=registry_filepath)
|
||||
|
||||
super().__init__(blockchain=token_agent.blockchain,
|
||||
registry_filepath=registry_filepath,
|
||||
*args, **kwargs)
|
||||
|
||||
def __init__(self, token_agent: NucypherTokenAgent, *args, **kwargs) -> None:
|
||||
super().__init__(blockchain=token_agent.blockchain, *args, **kwargs)
|
||||
self.token_agent = token_agent
|
||||
|
||||
#
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
from typing import List, Union
|
||||
|
||||
from constant_sorrow import constants
|
||||
from web3.middleware import geth_poa_middleware
|
||||
from constant_sorrow.constants import NO_BLOCKCHAIN_AVAILABLE
|
||||
from typing import Union
|
||||
from web3.contract import Contract
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface, BlockchainDeployerInterface
|
||||
from nucypher.config.blockchain import BlockchainConfiguration
|
||||
from nucypher.config.parsers import parse_blockchain_config
|
||||
|
||||
|
||||
class Blockchain:
|
||||
"""A view of a blockchain through a provided interface"""
|
||||
|
||||
_instance = None
|
||||
_default_network = NotImplemented
|
||||
_instance = NO_BLOCKCHAIN_AVAILABLE
|
||||
__default_interface_class = BlockchainInterface
|
||||
|
||||
test_chains = ('tester', 'temp')
|
||||
public_chains = ('mainnet', 'ropsten')
|
||||
|
||||
class ConnectionNotEstablished(RuntimeError):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue