示例#1
0
文件: status.py 项目: gs455/nucypher
def stakers(
        click_config,

        # Common Options
        provider_uri,
        geth,
        poa,
        light,
        registry_filepath,

        # Other
        staking_address):
    """
    Show relevant information about stakers.
    """
    # Init
    emitter = _setup_emitter(click_config)
    registry = _get_registry(click_config, emitter, geth, poa, light,
                             provider_uri, registry_filepath)

    staking_agent = ContractAgency.get_agent(StakingEscrowAgent,
                                             registry=registry)
    policy_agent = ContractAgency.get_agent(PolicyManagerAgent,
                                            registry=registry)

    stakers = [staking_address
               ] if staking_address else staking_agent.get_stakers()
    paint_stakers(emitter=emitter,
                  stakers=stakers,
                  staking_agent=staking_agent,
                  policy_agent=policy_agent)
示例#2
0
def stakers(general_config, registry_options, staking_address):
    """
    Show relevant information about stakers.
    """
    emitter = _setup_emitter(general_config)
    registry = registry_options.get_registry(emitter, general_config.debug)

    staking_agent = ContractAgency.get_agent(StakingEscrowAgent, registry=registry)
    policy_agent = ContractAgency.get_agent(PolicyManagerAgent, registry=registry)

    stakers = [staking_address] if staking_address else staking_agent.get_stakers()
    paint_stakers(emitter=emitter, stakers=stakers, staking_agent=staking_agent, policy_agent=policy_agent)
示例#3
0
文件: status.py 项目: y3v63n/nucypher
def stakers(general_config, registry_options, staking_address):
    """Show relevant information about stakers."""
    emitter, registry, blockchain = registry_options.setup(
        general_config=general_config)
    staking_agent = ContractAgency.get_agent(StakingEscrowAgent,
                                             registry=registry)
    policy_agent = ContractAgency.get_agent(PolicyManagerAgent,
                                            registry=registry)
    stakers_list = [staking_address
                    ] if staking_address else staking_agent.get_stakers()
    paint_stakers(emitter=emitter,
                  stakers=stakers_list,
                  staking_agent=staking_agent,
                  policy_agent=policy_agent)
示例#4
0
def stakers(click_config,

            # Common Options
            provider_uri, geth, poa, light, registry_filepath,

            # Other
            staking_address):
    """
    Show relevant information about stakers.
    """
    # Init
    emitter = _setup_emitter(click_config)
    staking_agent = _get_staking_agent(click_config, emitter, geth, poa, light, provider_uri, registry_filepath)

    stakers = [staking_address] if staking_address else staking_agent.get_stakers()
    paint_stakers(emitter=emitter, stakers=stakers, agent=staking_agent)
示例#5
0
文件: status.py 项目: zaxayn/nucypher
def status(click_config, action, provider_uri, sync, geth, poa, periods, staking_address, registry_filepath):
    """
    Echo a snapshot of live NuCypher Network metadata.

    \b
    Actions
    -------------------------------------------------
    network        Overall information of the NuCypher Network
    stakers        Show relevant information about stakers
    locked-tokens  Display a graph of evolution of locked tokens

    """

    emitter = click_config.emitter
    click.clear()
    emitter.banner(NU_BANNER)

    #
    # Connect to Blockchain
    #

    try:
        ETH_NODE = None
        if geth:
            ETH_NODE = get_provider_process()

        # Note: For test compatibility.
        if not BlockchainInterfaceFactory.is_interface_initialized(provider_uri=provider_uri):
            BlockchainInterfaceFactory.initialize_interface(provider_uri=provider_uri,
                                                            provider_process=ETH_NODE,
                                                            poa=poa,
                                                            sync=False,
                                                            show_sync_progress=False)

        blockchain = BlockchainInterfaceFactory.get_interface(provider_uri=provider_uri)

        emitter.echo(message="Reading Latest Chaindata...")
        blockchain.connect()
    except Exception as e:
        if click_config.debug:
            raise
        click.secho(str(e), bold=True, fg='red')
        raise click.Abort

    if registry_filepath:
        registry = LocalContractRegistry(filepath=registry_filepath)
    else:
        registry = InMemoryContractRegistry.from_latest_publication()

    staking_agent = ContractAgency.get_agent(StakingEscrowAgent, registry=registry)

    if action == 'network':
        paint_contract_status(registry, emitter=emitter)
        return  # Exit

    elif action == 'stakers':
        stakers = [staking_address] if staking_address else staking_agent.get_stakers()
        paint_stakers(emitter=emitter, stakers=stakers, agent=staking_agent)
        return  # Exit

    elif action == 'locked-tokens':
        paint_locked_tokens_status(emitter=emitter, agent=staking_agent, periods=periods)
        return  # Exit

    else:
        ctx = click.get_current_context()
        raise click.UsageError(message=f"Unknown action '{action}'.", ctx=ctx)