Exemplo n.º 1
0
    def __init__(self, name=None, password="", verbosity=None, file=False):

        cleos.set_local_nodeos_address_if_none()
        if name is None:
            name = setup.wallet_default_name
        else:
            name = setup.file_prefix() + name

        if not self.wallet is None:
            raise errors.Error('''
            It can be only one ``Wallet`` object in the script; there is one
            named ``{}``.
            '''.format(wallet.name))
            return

        self.wallet_dir = manager.wallet_dir()

        logger.INFO('''
                * Wallet name is ``{}``, wallet directory is
                    {}.
                '''.format(name, self.wallet_dir))

        if not password:  # look for password:
            passwords = wallet_json_read()
            if name in passwords:
                password = passwords[name]
                logger.INFO(
                    '''
                    The password is restored from the file:
                    {}
                    '''.format(
                        os.path.join(self.wallet_dir, setup.password_map)),
                    verbosity)

        cleos.WalletCreate.__init__(self, name, password, is_verbose=False)

        if self.is_created:  # new password
            logger.INFO(
                '''
                * Created wallet ``{}``.
                '''.format(self.name), verbosity)
            ###############################################################################
            # TO DO: detect live node!!!!!!!!!!
            if manager.is_local_testnet() or file or True:
                ###############################################################################
                password_map = wallet_json_read()
                password_map[name] = self.password
                wallet_json_write(password_map)
                logger.INFO(
                    '''
                    * Password is saved to the file ``{}`` in the wallet directory.
                    '''.format(setup.password_map), verbosity)
            else:
                logger.OUT(self.out_msg)
        else:
            logger.TRACE('''
                    Opened wallet ``{}``
                    '''.format(self.name))
Exemplo n.º 2
0
def resume(nodeos_stdout=None, verbosity=None):
    ''' Resume the EOSIO local node.
    ''' 
    if not cleos.set_local_nodeos_address_if_none():   
        logger.INFO('''
            Not local nodeos is set: {}
        '''.format(setup.nodeos_address()), verbosity)

    node_start(nodeos_stdout=nodeos_stdout, verbosity=verbosity)
Exemplo n.º 3
0
def reset(nodeos_stdout=None):
    ''' Start clean the local EOSIO node.

    The procedure addresses problems with instabilities of EOSIO *nodeos* 
    executable: it happens that it blocks itself on clean restart. 

    The issue is patched with one subsequent restart if the first attempt 
    fails. However, it happens that both launches fail, rarely due to 
    instability of *nodeos*, sometimes because of misconfiguration.

    When both launch attempts fail, an exception routine passes. At first,
    the command line is printed, for *example*::

        ERROR:
        The local ``nodeos`` failed to start twice in sequence. Perhaps, something is
        wrong with configuration of the system. See the command line issued:

        /usr/bin/nodeosx 
        --http-server-address 127.0.0.1:8888 
        --data-dir /mnt/c/Workspaces/EOS/eosfactory/localnode/ 
        --config-dir /mnt/c/Workspaces/EOS/eosfactory/localnode/ 
        --chain-state-db-size-mb 200 --contracts-console --verbose-http-errors --enable-stale-production --producer-name eosio 
        --signature-provider EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 
        --plugin eosio::producer_plugin 
        --plugin eosio::chain_api_plugin 
        --plugin eosio::http_plugin 
        --plugin eosio::history_api_plugin 
        --genesis-json /mnt/c/Workspaces/EOS/eosfactory/localnode/genesis.json
        --delete-all-blocks

    Next, the command line is executed, for *example*::

        Now, see the result of an execution of the command line.
        /bin/sh: 1: /usr/bin/nodeosx: not found

    The exemplary case is easy, it explains itself. Generally, the command 
    line given can be executed in a *bash* terminal separately, in order to 
    understand a problem.

    Args:
        nodeos_stdout (str): If set, a file where *stdout* stream of
            the local *nodeos* is send. Note that the file can be included to 
            the configuration of EOSFactory, see :func:`.core.config.nodeos_stdout`.
            If the file is set with the configuration, and in the same time 
            it is set with this argument, the argument setting prevails. 
    '''

    if not cleos.set_local_nodeos_address_if_none():
        logger.INFO('''
        No local nodeos is set: {}
        '''.format(setup.nodeos_address()))

    import eosfactory.shell.account as account
    teos.keosd_start()
    account.reboot()
    clear_testnet_cache()
    node_start(clear=True, nodeos_stdout=nodeos_stdout)
Exemplo n.º 4
0
def reset(verbosity=None):
    ''' Start clean the EOSIO local node.
    '''
    if not cleos.set_local_nodeos_address_if_none():
        logger.INFO('''
        No local nodeos is set: {}
        '''.format(setup.nodeos_address()), verbosity)

    import eosfactory.shell.account as account
    account.reboot()
    clear_testnet_cache()
    teos.node_start(clear=True, verbosity=verbosity)
Exemplo n.º 5
0
def resume(nodeos_stdout=None):
    ''' Resume the local EOSIO node.

    Args:
        nodeos_stdout (str): If set, a file where *stdout* stream of
            the local *nodeos* is send. Note that the file can be included to 
            the configuration of EOSFactory, see :func:`.core.config.nodeos_stdout`.
            If the file is set with the configuration, and in the same time 
            it is set with this argument, the argument setting prevails. 
    '''
    if not cleos.set_local_nodeos_address_if_none():
        logger.INFO('''
            Not local nodeos is set: {}
        '''.format(setup.nodeos_address()))

    node_start(nodeos_stdout=nodeos_stdout)
Exemplo n.º 6
0
def is_local_testnet():
    cleos.set_local_nodeos_address_if_none()
    return setup.is_local_address