Exemple #1
0
def main(  # pylint: disable=too-many-arguments
    private_key: str,
    state_db: str,
    web3: Web3,
    contracts: Dict[str, Contract],
    start_block: BlockNumber,
    confirmations: BlockNumber,
    min_reward: int,
    debug_shell: bool,
) -> int:
    """ The Monitoring service for the Raiden Network. """
    log.info("Starting Raiden Monitoring Service")

    ms = MonitoringService(
        web3=web3,
        private_key=private_key,
        contracts=contracts,
        sync_start_block=start_block,
        required_confirmations=confirmations,
        db_filename=state_db,
        min_reward=min_reward,
    )

    if debug_shell:
        import IPython

        IPython.embed()
        return 0

    ms.start()

    return 0
Exemple #2
0
def main(  # pylint: disable=too-many-arguments
    private_key: str,
    state_db: str,
    web3: Web3,
    contracts: Dict[str, Contract],
    start_block: BlockNumber,
    confirmations: BlockNumber,
    min_reward: int,
    debug_shell: bool,
) -> int:
    """ The Monitoring service for the Raiden Network. """
    log.info("Starting Raiden Monitoring Service")
    log.info("Web3 client", node_address=web3.providers[0].endpoint_uri)
    hex_addresses = {
        name: to_checksum_address(contract.address)
        for name, contract in contracts.items()
    }
    log.info("Contract information",
             addresses=hex_addresses,
             start_block=start_block)

    ms = MonitoringService(
        web3=web3,
        private_key=private_key,
        contracts=contracts,
        sync_start_block=start_block,
        required_confirmations=confirmations,
        db_filename=state_db,
        min_reward=min_reward,
    )

    if debug_shell:
        import IPython

        IPython.embed()
        return 0

    ms.start()

    return 0
Exemple #3
0
def main(
    private_key: str,
    state_db: str,
    web3: Web3,
    contracts: Dict[str, Contract],
    start_block: BlockNumber,
    confirmations: BlockNumber,
    min_reward: int,
) -> int:
    """ The Monitoring service for the Raiden Network. """
    log.info("Starting Raiden Monitoring Service")

    ms = MonitoringService(
        web3=web3,
        private_key=private_key,
        contracts=contracts,
        sync_start_block=start_block,
        required_confirmations=confirmations,
        db_filename=state_db,
        min_reward=min_reward,
    )
    ms.start()

    return 0
Exemple #4
0
def main(
    keystore_file: str,
    password: str,
    eth_rpc: str,
    registry_address: Address,
    monitor_contract_address: Address,
    user_deposit_contract_address: Address,
    start_block: int,
    confirmations: int,
    log_level: str,
    state_db: str,
    min_reward: int,
) -> None:
    setup_logging(log_level)

    with open(keystore_file, 'r') as keystore:
        try:
            private_key = Account.decrypt(
                keyfile_json=json.load(keystore),
                password=password,
            )
        except ValueError as error:
            log.critical(
                'Could not decode keyfile with given password. Please try again.',
                reason=str(error),
            )
            sys.exit(1)

    provider = HTTPProvider(eth_rpc)
    web3 = Web3(provider)
    contract_manager = ContractManager(contracts_precompiled_path())
    contract_infos = get_contract_addresses_and_start_block(
        chain_id=int(web3.net.version),
        contracts_version=None,
        token_network_registry_address=registry_address,
        monitor_contract_address=monitor_contract_address,
        user_deposit_contract_address=user_deposit_contract_address,
        start_block=start_block,
    )

    if contract_infos is None:
        log.critical(
            'Could not find correct contracts to use. Please check your configuration'
        )
        sys.exit(1)
    else:
        log.info(
            'Contract information',
            registry_address=contract_infos[CONTRACT_TOKEN_NETWORK_REGISTRY],
            monitor_contract_address=contract_infos[
                CONTRACT_MONITORING_SERVICE],
            user_deposit_contract_address=contract_infos[
                CONTRACT_USER_DEPOSIT],
            sync_start_block=contract_infos[START_BLOCK_ID],
        )

    ms = MonitoringService(
        web3=web3,
        contract_manager=contract_manager,
        private_key=private_key,
        registry_address=contract_infos[CONTRACT_TOKEN_NETWORK_REGISTRY],
        monitor_contract_address=contract_infos[CONTRACT_MONITORING_SERVICE],
        user_deposit_contract_address=contract_infos[CONTRACT_USER_DEPOSIT],
        sync_start_block=contract_infos[START_BLOCK_ID],
        required_confirmations=confirmations,
        db_filename=state_db,
        min_reward=min_reward,
    )
    ms.start()