Example #1
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')

    grand_parsers = parser.add_subparsers(title='grandchildcommands',
                                          dest='subcommand')
    grand_parsers.required = True

    epilog = '''details:
        Lists committed blocks from the newest to the oldest, including
    their id (i.e. header signature), batch and transaction count, and
    their signer's public key.
    '''
    grand_parsers.add_parser(
        'list', epilog=epilog,
        parents=[base_http_parser(), base_list_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)

    epilog = '''details:
        Shows the data for a single block, or for a particular property within
    that block or its header. Displays data in YAML (default), or JSON formats.
    '''
    show_parser = grand_parsers.add_parser(
        'show', epilog=epilog,
        parents=[base_http_parser(), base_show_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    show_parser.add_argument(
        'block_id',
        type=str,
        help='the id (i.e. header_signature) of the block')
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')
Example #3
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')
Example #4
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')
Example #5
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')
Example #6
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')
Example #7
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')
Example #8
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')

    grand_parsers = parser.add_subparsers(title='grandchildcommands',
                                          dest='subcommand')
    grand_parsers.required = True

    epilog = '''details:
        Lists state in the form of leaves from the merkle tree. List can be
    narrowed using the address of a subtree.
    '''
    list_parser = grand_parsers.add_parser(
        'list',
        epilog=epilog,
        parents=[base_http_parser(), base_list_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    list_parser.add_argument('subtree',
                             type=str,
                             nargs='?',
                             default=None,
                             help='the address of a subtree to filter list by')
    list_parser.add_argument(
        '--head',
        action='store',
        default=None,
        help='the id of the block to set as the chain head')

    epilog = '''details:
        Shows the data for a single leaf on the merkle tree.
    '''
    show_parser = grand_parsers.add_parser(
        'show',
        epilog=epilog,
        parents=[base_http_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    show_parser.add_argument('address',
                             type=str,
                             help='the address of the leaf')
    show_parser.add_argument(
        '--head',
        action='store',
        default=None,
        help='the id of the block to set as the chain head')
Example #9
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')

    grand_parsers = parser.add_subparsers(title='grandchildcommands',
                                          dest='subcommand')
    grand_parsers.required = True

    epilog = '''details:
        Lists state in the form of leaves from the merkle tree. List can be
    narrowed using the address of a subtree.
    '''
    list_parser = grand_parsers.add_parser(
        'list', epilog=epilog,
        parents=[base_http_parser(), base_list_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    list_parser.add_argument(
        'subtree',
        type=str,
        nargs='?',
        default=None,
        help='the address of a subtree to filter list by')
    list_parser.add_argument(
        '--head',
        action='store',
        default=None,
        help='the id of the block to set as the chain head')

    epilog = '''details:
        Shows the data for a single leaf on the merkle tree.
    '''
    show_parser = grand_parsers.add_parser(
        'show', epilog=epilog, parents=[base_http_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    show_parser.add_argument(
        'address',
        type=str,
        help='the address of the leaf')
    show_parser.add_argument(
        '--head',
        action='store',
        default=None,
        help='the id of the block to set as the chain head')
Example #10
0
def add_batch_status_parser(subparsers, parent_parser):
    epilog = '''details:
        Fetches the statuses for a set of batches.
    '''
    status_parser = subparsers.add_parser(
        'status', epilog=epilog,
        parents=[base_http_parser()])

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

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

    status_parser.add_argument(
        '-F', '--format',
        action='store',
        default='yaml',
        choices=['yaml', 'json'],
        help='the format to use for printing the output (defaults to yaml)')
Example #11
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
    )
Example #12
0
def add_batch_status_parser(subparsers, parent_parser):
    epilog = '''details:
        Fetches the statuses for a set of batches.
    '''
    status_parser = subparsers.add_parser('status',
                                          epilog=epilog,
                                          parents=[base_http_parser()])

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

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

    status_parser.add_argument(
        '-F',
        '--format',
        action='store',
        default='yaml',
        choices=['yaml', 'json'],
        help='the format to use for printing the output (defaults to yaml)')
Example #13
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='wait for batches to commit, set an integer to specify a timeout')

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

    submit_parser.add_argument(
        '--batch-size-limit',
        type=int,
        help='batches are split for processing if they exceed this size',
        default=100
    )
Example #14
0
def add_batch_status_parser(subparsers, parent_parser):
    """Adds arguments parsers for the batch-status commands

        Args:
            subparsers: Add parsers to this subparser object
            parent_parser: The parent argparse.ArgumentParser object
    """
    epilog = '''details:
        Fetches the statuses for a set of batches.
    '''
    parser = subparsers.add_parser('batch-status',
                                   epilog=epilog,
                                   parents=[base_http_parser(), parent_parser])

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

    parser.add_argument('batch_ids',
                        type=str,
                        help='a comma-separated list of batch ids')

    parser.add_argument(
        '-F',
        '--format',
        action='store',
        default='yaml',
        choices=['yaml', 'json'],
        help='the format to use for printing the output (defaults to yaml)')
Example #15
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()])
Example #16
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()])
Example #17
0
def add_batch_list_parser(subparsers, parent_parser):
    epilog = '''details:
        Lists committed batches from newest to oldest, including their id (i.e.
    header signature), transaction count, and their signer's public key.
    '''
    subparsers.add_parser(
        'list', epilog=epilog,
        parents=[base_http_parser(), base_list_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
Example #18
0
def add_batch_list_parser(subparsers, parent_parser):
    epilog = '''details:
        Lists committed batches from newest to oldest, including their id (i.e.
    header signature), transaction count, and their signer's public key.
    '''
    subparsers.add_parser('list',
                          epilog=epilog,
                          parents=[base_http_parser(),
                                   base_list_parser()],
                          formatter_class=argparse.RawDescriptionHelpFormatter)
Example #19
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')
Example #20
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)
Example #21
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')
Example #22
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)
Example #23
0
def add_batch_show_parser(subparsers, parent_parser):
    epilog = '''details:
        Shows the data for a single batch, or for a particular property within
    that batch or its header. Displays data in YAML (default), or JSON formats.
    '''
    show_parser = subparsers.add_parser(
        'show', epilog=epilog,
        parents=[base_http_parser(), base_show_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    show_parser.add_argument(
        'batch_id',
        type=str,
        help='the id (i.e. header_signature) of the batch')
Example #24
0
def add_batch_show_parser(subparsers, parent_parser):
    epilog = '''details:
        Shows the data for a single batch, or for a particular property within
    that batch or its header. Displays data in YAML (default), or JSON formats.
    '''
    show_parser = subparsers.add_parser(
        'show',
        epilog=epilog,
        parents=[base_http_parser(), base_show_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    show_parser.add_argument(
        'batch_id',
        type=str,
        help='the id (i.e. header_signature) of the batch')
Example #25
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')

    grand_parsers = parser.add_subparsers(title='grandchildcommands',
                                          dest='subcommand')
    grand_parsers.required = True

    epilog = '''details:
        Lists committed transactions from newest to oldest, including their id
    (i.e. header_signature), transaction family and version, and their payload.
    '''
    grand_parsers.add_parser(
        'list',
        epilog=epilog,
        parents=[base_http_parser(), base_list_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)

    epilog = '''details:
        Shows the data for a single transaction, or for a particular property
    within that transaction or its header. Displays data in YAML (default),
    or JSON formats.
    '''
    show_parser = grand_parsers.add_parser(
        'show',
        epilog=epilog,
        parents=[base_http_parser(), base_show_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    show_parser.add_argument(
        'transaction_id',
        type=str,
        help='the id (i.e. header_signature) of the transaction')
Example #26
0
def add_batch_submit_parser(subparsers, parent_parser):
    submit_parser = subparsers.add_parser(
        'submit', parents=[base_http_parser(), parent_parser])

    submit_parser.add_argument(
        '--wait',
        nargs='?',
        const=maxsize,
        type=int,
        help='wait for batches to commit, set an integer to specify a timeout')

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

    submit_parser.add_argument(
        '--batch-size-limit',
        type=int,
        help='batches are split for processing if they exceed this size',
        default=100)
Example #27
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)')
Example #28
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)')
Example #29
0
def add_batch_submit_parser(subparsers, parent_parser):
    submit_parser = subparsers.add_parser(
        'submit',
        parents=[base_http_parser(), parent_parser])

    submit_parser.add_argument(
        '--wait',
        nargs='?',
        const=maxsize,
        type=int,
        help='wait for batches to commit, set an integer to specify a timeout')

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

    submit_parser.add_argument(
        '--batch-size-limit',
        type=int,
        help='batches are split for processing if they exceed this size',
        default=100
    )