• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rest_client.RestClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sawtooth_cli.rest_client.RestClient的典型用法代码示例。如果您正苦于以下问题:Python RestClient类的具体用法?Python RestClient怎么用?Python RestClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了RestClient类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: do_batch_list

def do_batch_list(args):
    rest_client = RestClient(args.url, args.user)
    batches = rest_client.list_batches()
    keys = ('batch_id', 'txns', 'signer')
    headers = tuple(k.upper() for k in keys)

    def parse_batch_row(batch):
        return (
            batch['header_signature'],
            len(batch.get('transactions', [])),
            batch['header']['signer_pubkey'])

    if args.format == 'default':
        fmt.print_terminal_table(headers, batches, parse_batch_row)

    elif args.format == 'csv':
        fmt.print_csv(headers, batches, parse_batch_row)

    elif args.format == 'json' or args.format == 'yaml':
        data = [{k: d for k, d in zip(keys, parse_batch_row(b))}
                for b in batches]

        if args.format == 'yaml':
            fmt.print_yaml(data)
        elif args.format == 'json':
            fmt.print_json(data)
        else:
            raise AssertionError('Missing handler: {}'.format(args.format))

    else:
        raise AssertionError('Missing handler: {}'.format(args.format))
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:31,代码来源:batch.py


示例2: _do_config_proposal_vote

def _do_config_proposal_vote(args):
    """Executes the 'proposal vote' subcommand.  Given a key file, a proposal
    id and a vote value, it generates a batch of sawtooth_settings transactions
    in a BatchList instance.  The BatchList is file or submitted to a
    validator.
    """
    signer = _read_signer(args.key)
    rest_client = RestClient(args.url)

    proposals = _get_proposals(rest_client)

    proposal = None
    for candidate in proposals.candidates:
        if candidate.proposal_id == args.proposal_id:
            proposal = candidate
            break

    if proposal is None:
        raise CliException('No proposal exists with the given id')

    for vote_record in proposal.votes:
        if vote_record.public_key == signer.get_public_key().as_hex():
            raise CliException(
                'A vote has already been recorded with this signing key')

    txn = _create_vote_txn(
        signer,
        args.proposal_id,
        proposal.proposal.setting,
        args.vote_value)
    batch = _create_batch(signer, [txn])

    batch_list = BatchList(batches=[batch])

    rest_client.send_batches(batch_list)
开发者ID:jjason,项目名称:sawtooth-core,代码行数:35,代码来源:sawset.py


示例3: _do_config_proposal_create

def _do_config_proposal_create(args):
    """Executes the 'proposal create' subcommand.  Given a key file, and a
    series of key/value pairs, it generates batches of sawtooth_settings
    transactions in a BatchList instance.  The BatchList is either stored to a
    file or submitted to a validator, depending on the supplied CLI arguments.
    """
    settings = [s.split('=', 1) for s in args.setting]

    pubkey, signing_key = _read_signing_keys(args.key)

    txns = [_create_propose_txn(pubkey, signing_key, setting)
            for setting in settings]

    batch = _create_batch(pubkey, signing_key, txns)

    batch_list = BatchList(batches=[batch])

    if args.output is not None:
        try:
            with open(args.output, 'wb') as batch_file:
                batch_file.write(batch_list.SerializeToString())
        except IOError as e:
            raise CliException(
                'Unable to write to batch file: {}'.format(str(e)))
    elif args.url is not None:
        rest_client = RestClient(args.url)
        rest_client.send_batches(batch_list)
    else:
        raise AssertionError('No target for create set.')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:29,代码来源:config.py


示例4: _do_config_list

def _do_config_list(args):
    """Lists the current on-chain configuration values.
    """
    rest_client = RestClient(args.url)
    state = rest_client.list_state(subtree=SETTINGS_NAMESPACE)

    prefix = args.filter

    head = state['head']
    state_values = state['data']
    printable_settings = []
    proposals_address = _key_to_address('sawtooth.settings.vote.proposals')
    for state_value in state_values:
        if state_value['address'] == proposals_address:
            # This is completely internal setting and we won't list it here
            continue

        decoded = b64decode(state_value['data'])
        setting = Setting()
        setting.ParseFromString(decoded)

        for entry in setting.entries:
            if entry.key.startswith(prefix):
                printable_settings.append(entry)

    printable_settings.sort(key=lambda s: s.key)

    if args.format == 'default':
        tty_width = tty.width()
        for setting in printable_settings:
            # Set value width to the available terminal space, or the min width
            width = tty_width - len(setting.key) - 3
            width = width if width > _MIN_PRINT_WIDTH else _MIN_PRINT_WIDTH
            value = (setting.value[:width] + '...'
                     if len(setting.value) > width
                     else setting.value)
            print('{}: {}'.format(setting.key, value))
    elif args.format == 'csv':
        try:
            writer = csv.writer(sys.stdout, quoting=csv.QUOTE_ALL)
            writer.writerow(['KEY', 'VALUE'])
            for setting in printable_settings:
                writer.writerow([setting.key, setting.value])
        except csv.Error:
            raise CliException('Error writing CSV')
    elif args.format == 'json' or args.format == 'yaml':
        settings_snapshot = {
            'head': head,
            'settings': {setting.key: setting.value
                         for setting in printable_settings}
        }
        if args.format == 'json':
            print(json.dumps(settings_snapshot, indent=2, sort_keys=True))
        else:
            print(yaml.dump(settings_snapshot, default_flow_style=False)[0:-1])
    else:
        raise AssertionError('Unknown format {}'.format(args.format))
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:57,代码来源:config.py


示例5: do_state

def do_state(args):
    """Runs the batch list or batch show command, printing output to the
    console

        Args:
            args: The parsed arguments sent to the command at runtime
    """
    rest_client = RestClient(args.url, args.user)

    if args.subcommand == 'list':
        response = rest_client.list_state(args.subtree, args.head)
        leaves = response['data']
        head = response['head']
        keys = ('address', 'size', 'data')
        headers = tuple(k.upper() for k in keys)

        def parse_leaf_row(leaf, decode=True):
            decoded = b64decode(leaf['data'])
            return (
                leaf['address'],
                len(decoded),
                str(decoded) if decode else leaf['data'])

        if args.format == 'default':
            fmt.print_terminal_table(headers, leaves, parse_leaf_row)
            print('HEAD BLOCK: "{}"'.format(head))

        elif args.format == 'csv':
            fmt.print_csv(headers, leaves, parse_leaf_row)
            print('(data for head block: "{}")'.format(head))

        elif args.format == 'json' or args.format == 'yaml':
            state_data = {
                'head': head,
                'data': [{k: d for k, d in zip(keys, parse_leaf_row(l, False))}
                         for l in leaves]}

            if args.format == 'yaml':
                fmt.print_yaml(state_data)
            elif args.format == 'json':
                fmt.print_json(state_data)
            else:
                raise AssertionError('Missing handler: {}'.format(args.format))

        else:
            raise AssertionError('Missing handler: {}'.format(args.format))

    if args.subcommand == 'show':
        output = rest_client.get_leaf(args.address, args.head)
        if output is not None:
            print('DATA: "{}"'.format(b64decode(output['data'])))
            print('HEAD: "{}"'.format(output['head']))
        else:
            raise CliException('No data available at {}'.format(args.address))
开发者ID:Whiteblock,项目名称:sawtooth-core,代码行数:54,代码来源:state.py


示例6: do_peer_list

def do_peer_list(args):
    rest_client = RestClient(base_url=args.url)
    peers = sorted(rest_client.list_peers())

    if args.format == 'csv' or args.format == 'default':
        print(','.join(peers))

    elif args.format == 'json':
        fmt.print_json(peers)

    elif args.format == 'yaml':
        fmt.print_yaml(peers)
开发者ID:Whiteblock,项目名称:sawtooth-core,代码行数:12,代码来源:peer.py


示例7: _do_identity_role_create

def _do_identity_role_create(args):
    """Executes the 'role create' subcommand.  Given a key file, a role name,
    and a policy name it generates a batch of sawtooth_identity
    transactions in a BatchList instance. The BatchList is either stored to a
    file or submitted to a validator, depending on the supplied CLI arguments.
    """
    signer = _read_signer(args.key)
    txns = [_create_role_txn(signer, args.name,
                             args.policy)]

    batch = _create_batch(signer, txns)

    batch_list = BatchList(batches=[batch])

    if args.output is not None:
        try:
            with open(args.output, 'wb') as batch_file:
                batch_file.write(batch_list.SerializeToString())
        except IOError as e:
            raise CliException(
                'Unable to write to batch file: {}'.format(str(e)))
    elif args.url is not None:
        rest_client = RestClient(args.url)
        rest_client.send_batches(batch_list)
        if args.wait and args.wait > 0:
            batch_id = batch.header_signature
            wait_time = 0
            start_time = time.time()

            while wait_time < args.wait:
                statuses = rest_client.get_statuses(
                    [batch_id],
                    args.wait - int(wait_time))
                wait_time = time.time() - start_time

                if statuses[0]['status'] == 'COMMITTED':
                    print(
                        'Role committed in {:.6} sec'.format(wait_time))
                    return

                # Wait a moment so as not to hammer the Rest Api
                time.sleep(0.2)

            print('Wait timed out! Role was not committed...')
            print('{:128.128}  {}'.format(
                batch_id,
                statuses[0]['status']))
            exit(1)
    else:
        raise AssertionError('No target for create set.')
开发者ID:Whiteblock,项目名称:sawtooth-core,代码行数:50,代码来源:identity.py


示例8: _do_identity_role_list

def _do_identity_role_list(args):
    """Lists the current on-chain configuration values.
    """
    rest_client = RestClient(args.url)
    state = rest_client.list_state(subtree=IDENTITY_NAMESPACE + _ROLE_PREFIX)

    head = state['head']
    state_values = state['data']
    printable_roles = []
    for state_value in state_values:
        role_list = RoleList()
        decoded = b64decode(state_value['data'])
        role_list.ParseFromString(decoded)

        for role in role_list.roles:
            printable_roles.append(role)

    printable_roles.sort(key=lambda r: r.name)

    if args.format == 'default':
        tty_width = tty.width()
        for role in printable_roles:
            # Set value width to the available terminal space, or the min width
            width = tty_width - len(role.name) - 3
            width = width if width > _MIN_PRINT_WIDTH else _MIN_PRINT_WIDTH
            value = (role.policy_name[:width] + '...'
                     if len(role.policy_name) > width
                     else role.policy_name)
            print('{}: {}'.format(role.name, value))
    elif args.format == 'csv':
        try:
            writer = csv.writer(sys.stdout, quoting=csv.QUOTE_ALL)
            writer.writerow(['KEY', 'VALUE'])
            for role in printable_roles:
                writer.writerow([role.name, role.policy_name])
        except csv.Error:
            raise CliException('Error writing CSV')
    elif args.format == 'json' or args.format == 'yaml':
        roles_snapshot = {
            'head': head,
            'roles': {role.name: role.policy_name
                      for role in printable_roles}
        }
        if args.format == 'json':
            print(json.dumps(roles_snapshot, indent=2, sort_keys=True))
        else:
            print(yaml.dump(roles_snapshot, default_flow_style=False)[0:-1])
    else:
        raise AssertionError('Unknown format {}'.format(args.format))
开发者ID:Whiteblock,项目名称:sawtooth-core,代码行数:49,代码来源:identity.py


示例9: do_batch_submit

def do_batch_submit(args):

    try:
        with open(args.filename, mode='rb') as fd:
            batches = batch_pb2.BatchList()
            batches.ParseFromString(fd.read())
    except IOError as e:
        raise CliException(e)

    rest_client = RestClient(args.url, args.user)

    start = time.time()

    for batch_list in _split_batch_list(args, batches):
        rest_client.send_batches(batch_list)

    stop = time.time()

    print('batches: {},  batch/sec: {}'.format(
        str(len(batches.batches)),
        len(batches.batches) / (stop - start)))

    if args.wait and args.wait > 0:
        batch_ids = [b.header_signature for b in batches.batches]
        wait_time = 0
        start_time = time.time()

        while wait_time < args.wait:
            statuses = rest_client.get_statuses(
                batch_ids,
                args.wait - int(wait_time))
            wait_time = time.time() - start_time

            if all(s.status == 'COMMITTED' for s in statuses):
                print('All batches committed in {:.6} sec'.format(wait_time))
                return

            # Wait a moment so as not to hammer the Rest Api
            time.sleep(0.2)

        print('Wait timed out! Some batches have not yet been committed...')
        for batch_id, status in statuses.items():
            print('{:128.128}  {:10.10}'.format(batch_id, status))
        exit(1)
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:44,代码来源:batch.py


示例10: do_batch_show

def do_batch_show(args):
    rest_client = RestClient(args.url, args.user)
    output = rest_client.get_batch(args.batch_id)

    if args.key:
        if args.key in output:
            output = output[args.key]
        elif args.key in output['header']:
            output = output['header'][args.key]
        else:
            raise CliException(
                'key "{}" not found in batch or header'.format(args.key))

    if args.format == 'yaml':
        fmt.print_yaml(output)
    elif args.format == 'json':
        fmt.print_json(output)
    else:
        raise AssertionError('Missing handler: {}'.format(args.format))
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:19,代码来源:batch.py


示例11: do_batch_status

def do_batch_status(args):
    """Runs the batch-status command, printing output to the console

        Args:
            args: The parsed arguments sent to the command at runtime
    """
    rest_client = RestClient(args.url, args.user)
    batch_ids = args.batch_ids.split(',')

    if args.wait and args.wait > 0:
        statuses = rest_client.get_statuses(batch_ids, args.wait)
    else:
        statuses = rest_client.get_statuses(batch_ids)

    if args.format == 'yaml':
        fmt.print_yaml(statuses)
    elif args.format == 'json':
        fmt.print_json(statuses)
    else:
        raise AssertionError('Missing handler: {}'.format(args.format))
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:20,代码来源:batch.py


示例12: do_block

def do_block(args):
    """Runs the block list or block show command, printing output to the
    console

        Args:
            args: The parsed arguments sent to the command at runtime
    """
    rest_client = RestClient(args.url, args.user)

    if args.subcommand == 'list':
        block_generator = rest_client.list_blocks()
        blocks = []
        left = args.count
        for block in block_generator:
            blocks.append(block)
            left -= 1
            if left <= 0:
                break

        keys = ('num', 'block_id', 'batches', 'txns', 'signer')
        headers = tuple(k.upper() if k != 'batches' else 'BATS' for k in keys)

        def parse_block_row(block):
            batches = block.get('batches', [])
            txns = [t for b in batches for t in b['transactions']]
            return (
                block['header'].get('block_num', 0),
                block['header_signature'],
                len(batches),
                len(txns),
                block['header']['signer_public_key'])

        if args.format == 'default':
            fmt.print_terminal_table(headers, blocks, parse_block_row)

        elif args.format == 'csv':
            fmt.print_csv(headers, blocks, parse_block_row)

        elif args.format == 'json' or args.format == 'yaml':
            data = [{k: d for k, d in zip(keys, parse_block_row(b))}
                    for b in blocks]

            if args.format == 'yaml':
                fmt.print_yaml(data)
            elif args.format == 'json':
                fmt.print_json(data)
            else:
                raise AssertionError('Missing handler: {}'.format(args.format))

        else:
            raise AssertionError('Missing handler: {}'.format(args.format))

    if args.subcommand == 'show':
        output = rest_client.get_block(args.block_id)

        if args.key:
            if args.key in output:
                output = output[args.key]
            elif args.key in output['header']:
                output = output['header'][args.key]
            else:
                raise CliException(
                    'key "{}" not found in block or header'.format(args.key))

        if args.format == 'yaml':
            fmt.print_yaml(output)
        elif args.format == 'json':
            fmt.print_json(output)
        else:
            raise AssertionError('Missing handler: {}'.format(args.format))
开发者ID:Whiteblock,项目名称:sawtooth-core,代码行数:70,代码来源:block.py


示例13: __init__

 def __init__(self, url):
     self._client = RestClient(base_url="http://{}".format(url))
开发者ID:delventhalz,项目名称:sawtooth-mktplace,代码行数:2,代码来源:blockchain_integration_test.py


示例14: do_transaction

def do_transaction(args):
    """Runs the transaction list or show command, printing to the console

        Args:
            args: The parsed arguments sent to the command at runtime
    """
    rest_client = RestClient(args.url, args.user)

    if args.subcommand == 'list':
        transactions = rest_client.list_transactions()
        keys = ('transaction_id', 'family', 'version', 'size', 'payload')
        headers = tuple(k.upper() if k != 'version' else 'VERS' for k in keys)

        def parse_txn_row(transaction, decode=True):
            decoded = b64decode(transaction['payload'])
            return (
                transaction['header_signature'],
                transaction['header']['family_name'],
                transaction['header']['family_version'],
                len(decoded),
                str(decoded) if decode else transaction['payload'])

        if args.format == 'default':
            fmt.print_terminal_table(headers, transactions, parse_txn_row)

        elif args.format == 'csv':
            fmt.print_csv(headers, transactions, parse_txn_row)

        elif args.format == 'json' or args.format == 'yaml':
            data = [{k: d for k, d in zip(keys, parse_txn_row(b, False))}
                    for b in transactions]

            if args.format == 'yaml':
                fmt.print_yaml(data)
            elif args.format == 'json':
                fmt.print_json(data)
            else:
                raise AssertionError('Missing handler: {}'.format(args.format))

        else:
            raise AssertionError('Missing handler: {}'.format(args.format))

    if args.subcommand == 'show':
        output = rest_client.get_transaction(args.transaction_id)

        if args.key:
            if args.key == 'payload':
                output = b64decode(output['payload'])
            elif args.key in output:
                output = output[args.key]
            elif args.key in output['header']:
                output = output['header'][args.key]
            else:
                raise CliException(
                    'Key "{}" not found in transaction or header'.format(
                        args.key))

        if args.format == 'yaml':
            fmt.print_yaml(output)
        elif args.format == 'json':
            fmt.print_json(output)
        else:
            raise AssertionError('Missing handler: {}'.format(args.format))
开发者ID:Whiteblock,项目名称:sawtooth-core,代码行数:63,代码来源:transaction.py


示例15: do_block

def do_block(args):
    subcommands = ['list', 'show']
    if args.subcommand not in subcommands:
        print('Unknown sub-command, expecting one of {0}'.format(
            subcommands))
        return

    rest_client = RestClient(args.url)

    def print_json(data):
        print(json.dumps(
            data,
            indent=2,
            separators=(',', ': '),
            sort_keys=True))

    def print_yaml(data):
        print(yaml.dump(data, default_flow_style=False)[0:-1])

    if args.subcommand == 'list':
        blocks = rest_client.list_blocks()
        keys = ('num', 'block_id', 'batches', 'txns', 'signer')
        headers = (k.upper() for k in keys)

        def get_block_data(block):
            batches = block.get('batches', [])
            txn_count = reduce(
                lambda t, b: t + len(b.get('transactions', [])),
                batches,
                0)

            return (
                block['header'].get('block_num', 0),
                block['header_signature'],
                len(batches),
                txn_count,
                block['header']['signer_pubkey']
            )

        if args.format == 'default':
            print('{:<3}  {:88.88}  {:<7}  {:<4}  {:20.20}'.format(*headers))

            for block in blocks:
                print('{:<3}  {:88.88}  {:<7}  {:<4}  {:17.17}...'.format(
                    *get_block_data(block)))

        elif args.format == 'csv':
            try:
                writer = csv.writer(sys.stdout)
                writer.writerow(headers)
                for block in blocks:
                    writer.writerow(get_block_data(block))
            except csv.Error:
                raise CliException('Error writing CSV.')

        elif args.format == 'json' or args.format == 'yaml':
            block_data = list(map(
                lambda b: dict(zip(keys, get_block_data(b))),
                blocks
            ))

            if args.format == 'json':
                print_json(block_data)
            else:
                print_yaml(block_data)

        else:
            raise CliException('unknown format: {}'.format(args.format))

    elif args.subcommand == 'show':
        block = rest_client.get_block(args.block_id)

        if args.key:
            if args.key in block:
                print(block[args.key])
            elif args.key in block['header']:
                print(block['header'][args.key])
            else:
                raise CliException(
                    'key "{}" not found in block or header'.format(args.key))
        else:
            if args.format == 'yaml':
                print_yaml(block)
            elif args.format == 'json':
                print_json(block)
            else:
                raise CliException('unknown format: {}'.format(args.format))
开发者ID:jsmitchell,项目名称:sawtooth-core,代码行数:87,代码来源:block.py


示例16: _do_identity_policy_list

def _do_identity_policy_list(args):
    rest_client = RestClient(args.url)
    state = rest_client.list_state(subtree=IDENTITY_NAMESPACE + _POLICY_PREFIX)

    head = state['head']
    state_values = state['data']
    printable_policies = []
    for state_value in state_values:
        policies_list = PolicyList()
        decoded = b64decode(state_value['data'])
        policies_list.ParseFromString(decoded)

        for policy in policies_list.policies:
            printable_policies.append(policy)

    printable_policies.sort(key=lambda p: p.name)

    if args.format == 'default':
        tty_width = tty.width()
        for policy in printable_policies:
            # Set value width to the available terminal space, or the min width
            width = tty_width - len(policy.name) - 3
            width = width if width > _MIN_PRINT_WIDTH else _MIN_PRINT_WIDTH
            value = "Entries:\n"
            for entry in policy.entries:
                entry_string = (" " * 4) + Policy.EntryType.Name(entry.type) \
                    + " " + entry.key
                value += (entry_string[:width] + '...'
                          if len(entry_string) > width
                          else entry_string) + "\n"
            print('{}: \n  {}'.format(policy.name, value))
    elif args.format == 'csv':
        try:
            writer = csv.writer(sys.stdout, quoting=csv.QUOTE_ALL)
            writer.writerow(['POLICY NAME', 'ENTRIES'])
            for policy in printable_policies:
                output = [policy.name]
                for entry in policy.entries:
                    output.append(
                        Policy.EntryType.Name(entry.type) + " " + entry.key)
                writer.writerow(output)
        except csv.Error:
            raise CliException('Error writing CSV')
    elif args.format == 'json' or args.format == 'yaml':
        output = {}
        for policy in printable_policies:
            value = "Entries: "
            for entry in policy.entries:
                entry_string = Policy.EntryType.Name(entry.type) + " " \
                    + entry.key
                value += entry_string + " "
            output[policy.name] = value

        policies_snapshot = {
            'head': head,
            'policies': output
        }
        if args.format == 'json':
            print(json.dumps(policies_snapshot, indent=2, sort_keys=True))
        else:
            print(yaml.dump(policies_snapshot, default_flow_style=False)[0:-1])
    else:
        raise AssertionError('Unknown format {}'.format(args.format))
开发者ID:Whiteblock,项目名称:sawtooth-core,代码行数:63,代码来源:identity.py


示例17: MarketplaceClient

class MarketplaceClient(object):

    def __init__(self, url):
        self._client = RestClient(base_url="http://{}".format(url))

    def create_account(self, key, label, description):
        batches, signature = transaction_creation.create_account(
            txn_key=key,
            batch_key=BATCH_KEY,
            label=label,
            description=description)
        batch_list = batch_pb2.BatchList(batches=batches)

        self._client.send_batches(batch_list)
        return self._client.get_statuses([signature], wait=10)

    def create_asset(self, key, name, description, rules):
        batches, signature = transaction_creation.create_asset(
            txn_key=key,
            batch_key=BATCH_KEY,
            name=name,
            description=description,
            rules=rules)
        batch_list = batch_pb2.BatchList(batches=batches)
        self._client.send_batches(batch_list)
        return self._client.get_statuses([signature], wait=10)

    def create_holding(self,
                       key,
                       identifier,
                       label,
                       description,
                       asset,
                       quantity):
        batches, signature = transaction_creation.create_holding(
            txn_key=key,
            batch_key=BATCH_KEY,
            identifier=identifier,
            label=label,
            description=description,
            asset=asset,
            quantity=quantity)
        batch_list = batch_pb2.BatchList(batches=batches)
        self._client.send_batches(batch_list)
        return self._client.get_statuses([signature], wait=10)

    def create_offer(self,
                     key,
                     identifier,
                     label,
                     description,
                     source,
                     target,
                     rules):
        batches, signature = transaction_creation.create_offer(
            txn_key=key,
            batch_key=BATCH_KEY,
            identifier=identifier,
            label=label,
            description=description,
            source=source,
            target=target,
            rules=rules)
        batch_list = batch_pb2.BatchList(batches=batches)
        self._client.send_batches(batch_list)
        return self._client.get_statuses([signature], wait=10)

    def accept_offer(self,
                     key,
                     identifier,
                     receiver,
                     offerer,
                     count):
        batches, signature = transaction_creation.accept_offer(
            txn_key=key,
            batch_key=BATCH_KEY,
            identifier=identifier,
            offerer=offerer,
            receiver=receiver,
            count=count)
        batch_list = batch_pb2.BatchList(batches=batches)
        self._client.send_batches(batch_list)
        return self._client.get_statuses([signature], wait=10)

    def close_offer(self,
                    key,
                    identifier):
        batches, signature = transaction_creation.close_offer(
            txn_key=key,
            batch_key=BATCH_KEY,
            identifier=identifier)

        batch_list = batch_pb2.BatchList(batches=batches)
        self._client.send_batches(batch_list)
        return self._client.get_statuses([signature], wait=10)
开发者ID:delventhalz,项目名称:sawtooth-mktplace,代码行数:95,代码来源:blockchain_integration_test.py



注:本文中的sawtooth_cli.rest_client.RestClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap