Esempio n. 1
0
def add_transaction_parser(subparsers, parent_parser):
    """Adds argument parsers for the transaction list and show commands

        Args:
            subparsers: Add parsers to this subparser object
            parent_parser: The parent argparse.ArgumentParser object
    """
    parser = subparsers.add_parser(
        'transaction',
        help='Shows information on transactions in the current chain',
        description='Provides subcommands to display information about '
        'the transactions in the current blockchain.')

    grand_parsers = parser.add_subparsers(
        title='subcommands',
        dest='subcommand')

    grand_parsers.required = True

    grand_parsers.add_parser(
        'list',
        description='Lists all transactions in the current blockchain.',
        parents=[base_http_parser(), base_list_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)

    show_parser = grand_parsers.add_parser(
        'show',
        description='Displays information for the specified transaction.',
        parents=[base_http_parser(), base_show_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)

    show_parser.add_argument(
        'transaction_id',
        type=str,
        help='id (header_signature) of the transaction')
Esempio n. 2
0
def add_block_parser(subparsers, parent_parser):
    """Adds arguments parsers for the block list and block show commands

        Args:
            subparsers: Add parsers to this subparser object
            parent_parser: The parent argparse.ArgumentParser object
    """
    parser = subparsers.add_parser(
        'block',
        description='Provides subcommands to display information about the '
        'blocks in the current blockchain.',
        help='Displays information on blocks in the current blockchain')

    grand_parsers = parser.add_subparsers(
        title='subcommands',
        dest='subcommand')

    grand_parsers.required = True

    description = (
        'Displays information for all blocks on the current '
        'blockchain, including the block id and number, public keys all '
        'of allsigners, and number of transactions and batches.')

    list_parser = grand_parsers.add_parser(
        'list',
        help='Displays information for all blocks on the current blockchain',
        description=description,
        parents=[base_http_parser(), base_list_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)

    list_parser.add_argument(
        '-n',
        '--count',
        default=100,
        type=int,
        help='the number of blocks to list',
    )

    description = (
        'Displays information about the specified block on '
        'the current blockchain')

    show_parser = grand_parsers.add_parser(
        'show',
        help=description,
        description=description + '.',
        parents=[base_http_parser(), base_show_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    show_parser.add_argument(
        'block_id',
        type=str,
        help='id (header_signature) of the block')
Esempio n. 3
0
def add_state_parser(subparsers, parent_parser):
    """Adds arguments parsers for the state list and state show commands

        Args:
            subparsers: Add parsers to this subparser object
            parent_parser: The parent argparse.ArgumentParser object
    """
    parser = subparsers.add_parser(
        'state',
        help='Displays information on the entries in state',
        description='Provides subcommands to display information about the '
        'state entries in the current blockchain state.')

    grand_parsers = parser.add_subparsers(title='subcommands',
                                          dest='subcommand')

    grand_parsers.required = True

    list_parser = grand_parsers.add_parser(
        'list',
        description='Lists all state entries in the current blockchain.',
        parents=[base_http_parser(), base_list_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)

    list_parser.add_argument('subtree',
                             type=str,
                             nargs='?',
                             default=None,
                             help='address of a subtree to filter the list by')

    list_parser.add_argument(
        '--head',
        action='store',
        default=None,
        help='specify the id of the block to set as the chain head')

    show_parser = grand_parsers.add_parser(
        'show',
        description='Displays information for the specified state address in '
        'the current blockchain.',
        parents=[base_http_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)

    show_parser.add_argument('address', type=str, help='address of the leaf')

    show_parser.add_argument(
        '--head',
        action='store',
        default=None,
        help='specify the id of the block to set as the chain head')
Esempio n. 4
0
def add_status_show_parser(subparsers, parent_parser):
    description = ('Displays information about the status of a validator.')

    subparsers.add_parser('show',
                          description=description,
                          parents=[base_http_parser(),
                                   base_list_parser()])
Esempio n. 5
0
def add_batch_submit_parser(subparsers, parent_parser):
    submit_parser = subparsers.add_parser(
        'submit',
        description='Sends Batches to the REST API to be submitted to the '
        'validator. The input must be a binary file containing a '
        'binary-encoded BatchList of one or more batches with any number '
        'of transactions.',
        parents=[base_http_parser(), parent_parser])

    submit_parser.add_argument(
        '--wait',
        nargs='?',
        const=maxsize,
        type=int,
        help='set time, in seconds, to wait for batches to commit')

    submit_parser.add_argument('-f',
                               '--filename',
                               type=str,
                               help='specify location of input file',
                               default='batches.intkey')

    submit_parser.add_argument(
        '--batch-size-limit',
        type=int,
        help='set maximum batch size; batches are split for processing '
        'if they exceed this size',
        default=100)
Esempio n. 6
0
def add_peer_list_parser(subparsers, parent_parser):
    description = (
        'Displays the addresses of the validators with which '
        'a specified validator is peered.')

    subparsers.add_parser(
        'list',
        description=description,
        parents=[base_http_parser(), base_list_parser()])
Esempio n. 7
0
def add_batch_show_parser(subparsers, parent_parser):
    show_parser = subparsers.add_parser(
        'show',
        description='Displays information for the specified Batch.',
        parents=[base_http_parser(), base_show_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)

    show_parser.add_argument('batch_id',
                             type=str,
                             help='id (header_signature) of the batch')
Esempio n. 8
0
def add_batch_list_parser(subparsers, parent_parser):
    description = (
        'Displays all information about all committed Batches for '
        'the specified validator, including the Batch id, public keys of all '
        'signers, and number of transactions in each Batch.')

    subparsers.add_parser('list',
                          description=description,
                          parents=[base_http_parser(),
                                   base_list_parser()],
                          formatter_class=argparse.RawDescriptionHelpFormatter)
Esempio n. 9
0
def add_batch_status_parser(subparsers, parent_parser):
    status_parser = subparsers.add_parser(
        'status',
        description='Displays the status of the specified Batch id or ids.',
        parents=[base_http_parser()])

    status_parser.add_argument('--wait',
                               nargs='?',
                               const=maxsize,
                               type=int,
                               help='set time, in seconds, to wait for commit')

    status_parser.add_argument(
        'batch_ids',
        type=str,
        help='single batch id or comma-separated list of batch ids')

    status_parser.add_argument('-F',
                               '--format',
                               action='store',
                               default='yaml',
                               choices=['yaml', 'json'],
                               help='choose the output format (default: yaml)')