Esempio n. 1
0
def _start_app(config, account):
    # create app
    app = HPCApp(config)

    # development mode
    if False:
        gevent.get_hub().SYSTEM_ERROR = BaseException

    # dump config
    pyethapp_app.dump_config(config)
    # init accounts first, as we need (and set by copy) the coinbase early FIXME
    if AccountsService in services:
        AccountsService.register_with_app(app)
    # add account
    app.services.accounts.add_account(account, store=False)

    assert app.services.accounts.coinbase in config['hdc']['validators']
    # register services
    for service in services:
        assert issubclass(service, BaseService)
        if service.name not in app.config['deactivated_services'] + [AccountsService.name]:
            assert service.name not in app.services
            service.register_with_app(app)
            assert hasattr(app.services, service.name)

    # start app
    log.info('starting')
    app.start()
    if config['post_app_start_callback'] is not None:
        config['post_app_start_callback'](app)
    return app
Esempio n. 2
0
def start_app(config, account):
    # create app
    app = HPCApp(config)

    # development mode
    if False:
        gevent.get_hub().SYSTEM_ERROR = BaseException

    # dump config
    pyethapp_app.dump_config(config)
    # init accounts first, as we need (and set by copy) the coinbase early FIXME
    if AccountsService in services:
        AccountsService.register_with_app(app)
    # add account
    app.services.accounts.add_account(account, store=False)

    assert app.services.accounts.coinbase in config['hdc']['validators']
    # register services
    for service in services:
        assert issubclass(service, BaseService)
        if service.name not in app.config['deactivated_services'] + [
                AccountsService.name
        ]:
            assert service.name not in app.services
            service.register_with_app(app)
            assert hasattr(app.services, service.name)

    # start app
    log.info('starting')
    app.start()
    if config['post_app_start_callback'] is not None:
        config['post_app_start_callback'](app)
    return app
Esempio n. 3
0
def start_app(config, accounts):

    # create app
    app = HPCApp(config)

    # development mode
    if False:
        gevent.get_hub().SYSTEM_ERROR = BaseException

    if config['test_privkeys']:
        # init accounts first, as we need (and set by copy) the coinbase early FIXME
        genesis_config = dict(alloc=dict())
        for privkey in config['test_privkeys']:
            assert len(privkey) == 32
            address = privtoaddr(privkey)
            account = Account.new(password='', key=privkey)
            accounts.append(account)
            # add to genesis alloc
            genesis_config['alloc'][address] = {'wei': config['test_privkeys_endowment']}

        if config['test_privkeys'] and config['eth'].get('genesis_hash'):
            del config['eth']['genesis_hash']

        konfig.update_config_from_genesis_json(config, genesis_config)

    # dump config
    pyethapp_app.dump_config(config)

    if AccountsService in services:
        AccountsService.register_with_app(app)

    # add account
    for account in accounts:
        app.services.accounts.add_account(account, store=False)

    if config['hdc']['validators']:
        assert app.services.accounts.coinbase in config['hdc']['validators']

    # register services
    for service in services:
        assert issubclass(service, BaseService)
        if service.name not in app.config['deactivated_services'] + [AccountsService.name]:
            assert service.name not in app.services
            service.register_with_app(app)
            assert hasattr(app.services, service.name)

    # start app
    log.info('starting')
    app.start()
    for cb in config['post_app_start_callbacks']:
        cb(app)
    return app
Esempio n. 4
0
def _start_app(account, config, validators):
    # create app
    app = HPCApp(config)
    # development mode
    if True:
        gevent.get_hub().SYSTEM_ERROR = BaseException

    # dump config
    pyethapp_app.dump_config(config)
    # init accounts first, as we need (and set by copy) the coinbase early FIXME
    if AccountsService in services:
        AccountsService.register_with_app(app)
    # add account
    app.services.accounts.add_account(account, store=False)

    assert app.services.accounts.coinbase in validators
    # register services
    for service in services:
        assert issubclass(service, BaseService)
        if service.name not in app.config['deactivated_services'] + [AccountsService.name]:
            assert service.name not in app.services
            service.register_with_app(app)
            assert hasattr(app.services, service.name)

    # start app
    log.info('starting')
    app.start()
    if config['post_app_start_callback'] is not None:
        config['post_app_start_callback'](app)

    # wait for interrupt
    evt = Event()
    gevent.signal(signal.SIGQUIT, evt.set)
    gevent.signal(signal.SIGTERM, evt.set)
    gevent.signal(signal.SIGINT, evt.set)
    evt.wait()
    # finally stop
    app.stop()