from .libindy import do_call, create_cb
from typing import Optional
from ctypes import *
import logging
async def sign_and_submit_request(pool_handle: int,
wallet_handle: int,
submitter_did: str,
request_json: str) -> str:
"""
Signs and submits request message to validator pool.
Adds submitter information to passed request json, signs it with submitter
sign key (see wallet_sign), and sends signed request message
to validator pool (see write_request).
:param pool_handle: pool handle (created by open_pool_ledger).
:param wallet_handle: wallet handle (created by open_wallet).
:param submitter_did: Id of Identity stored in secured Wallet.
:param request_json: Request data json.
:return: Request result as json.
"""
logger = logging.getLogger(__name__)
logger.debug("sign_and_submit_request: >>> pool_handle: %r, wallet_handle: %r, submitter_did: %r, request_json: %r",
pool_handle,
wallet_handle,
submitter_did,
request_json)
if not hasattr(sign_and_submit_request, "cb"):
logger.debug("sign_and_submit_request: Creating callback")
sign_and_submit_request.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))
c_pool_handle = c_int32(pool_handle)
c_wallet_handle = c_int32(wallet_handle)
c_submitter_did = c_char_p(submitter_did.encode('utf-8'))
c_request_json = c_char_p(request_json.encode('utf-8'))
request_result = await do_call('indy_sign_and_submit_request',
c_pool_handle,
c_wallet_handle,
c_submitter_did,
c_request_json,
sign_and_submit_request.cb)
res = request_result.decode()
logger.debug("sign_and_submit_request: <<< res: %r", res)
return res
async def submit_request(pool_handle: int,
request_json: str) -> str:
"""
Publishes request message to validator pool (no signing, unlike sign_and_submit_request).
The request is sent to the validator pool as is. It's assumed that it's already prepared.
:param pool_handle: pool handle (created by open_pool_ledger).
:param request_json: Request data json.
:return: Request result as json.
"""
logger = logging.getLogger(__name__)
logger.debug("submit_request: >>> pool_handle: %r, request_json: %r",
pool_handle,
request_json)
if not hasattr(submit_request, "cb"):
logger.debug("submit_request: Creating callback")
submit_request.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))
c_pool_handle = c_int32(pool_handle)
c_request_json = c_char_p(request_json.encode('utf-8'))
request_result = await do_call('indy_submit_request',
c_pool_handle,
c_request_json,
submit_request.cb)
res = request_result.decode()
logger.debug("submit_request: <<< res: %r", res)
return res
async def submit_action(pool_handle: int,
request_json: str,
nodes: Optional[str],
timeout: Optional[int]) -> str:
"""
Send action to particular nodes of validator pool.
The list of requests can be send:
POOL_RESTART
GET_VALIDATOR_INFO
The request is sent to the nodes as is. It's assumed that it's already prepared.
:param pool_handle: pool handle (created by open_pool_ledger).
:param request_json: Request data json.
:param nodes: (Optional) List of node names to send the request.
["Node1", "Node2",...."NodeN"]
:param timeout: (Optional) Time to wait respond from nodes (override the default timeout) (in sec).
:return: Request result as json.
"""
logger = logging.getLogger(__name__)
logger.debug("submit_action: >>> pool_handle: %r, request_json: %r, nodes: %r, timeout: %r",
pool_handle,
request_json,
nodes,
timeout)
if not hasattr(submit_action, "cb"):
logger.debug("submit_action: Creating callback")
submit_action.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))
c_pool_handle = c_int32(pool_handle)
c_request_json = c_char_p(request_json.encode('utf-8'))
c_nodes = c_char_p(nodes.encode('utf-8')) if nodes is not None else None
c_timeout = c_int32(timeout) if timeout is not None else None
request_result = await do_call('indy_submit_action',
c_pool_handle,
c_request_json,
c_nodes,
c_timeout,
submit_action.cb)
res = request_result.decode()
logger.debug("submit_action: <<< res: %r", res)
return res
async def sign_request(wallet_handle: int,
submitter_did: str,
request_json: str) -> str:
"""
Signs request message.
Adds submitter information to passed request json, signs it with submitter
sign key (see wallet_sign).
:param wallet_handle: wallet handle (created by open_wallet).
:param submitter_did: Id of Identity stored in secured Wallet.
:param request_json: Request data json.
:return: Signed request json.
"""
logger = logging.getLogger(__name__)
logger.debug("sign_request: >>> wallet_handle: %r, submitter_did: %r, request_json: %r",
wallet_handle,
submitter_did,
request_json)
if not hasattr(sign_request, "cb"):
logger.debug("sign_and_submit_request: Creating callback")
sign_request.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))
c_wallet_handle = c_int32(wallet_handle)
c_submitter_did = c_char_p(submitter_did.encode('utf-8'))
c_request_json = c_char_p(request_json.encode('utf-8'))
request_result = await do_call('indy_sign_request',
c_wallet_handle,
c_submitter_did,
c_request_json,
sign_request.cb)
res = request_result.decode()
logger.debug("sign_request: <<< res: %r", res)
return res
async def multi_sign_request(wallet_handle: int,
submitter_did: str,
request_json: str) -> str:
"""
Multi signs request message.
Adds submitter information to passed request json, signs it with submitter
sign key (see wallet_sign).
:param wallet_handle: wallet handle (created by open_wallet).
:param submitter_did: Id of Identity stored in secured Wallet.
:param request_json: Request data json.
:return: Signed request json.
"""
logger = logging.getLogger(__name__)
logger.debug("multi_sign_request: >>> wallet_handle: %r, submitter_did: %r, request_json: %r",
wallet_handle,
submitter_did,
request_json)
if not hasattr(multi_sign_request, "cb"):
logger.debug("sign_and_submit_request: Creating callback")
multi_sign_request.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))
c_wallet_handle = c_int32(wallet_handle)
c_submitter_did = c_char_p(submitter_did.encode('utf-8'))
c_request_json = c_char_p(request_json.encode('utf-8'))
request_result = await do_call('indy_multi_sign_request',
c_wallet_handle,
c_submitter_did,
c_request_json,
multi_sign_request.cb)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源分类:Python库 所属语言:Python 资源全名:python3-indy-1.8.3-dev-1097.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
python3-indy-1.8.3-dev-1097.tar.gz (15个子文件)
python3-indy-1.8.3-dev-1097
PKG-INFO 506B
setup.py 742B
indy
crypto.py 19KB
non_secrets.py 17KB
pool.py 7KB
blob_storage.py 1KB
wallet.py 16KB
libindy.py 7KB
__init__.py 491B
pairwise.py 6KB
payment.py 29KB
did.py 21KB
anoncreds.py 69KB
error.py 6KB
ledger.py 71KB
共 15 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 1731260448754.jpeg
- 博图 博途1s保护解除DLL Siemens.Automation.AdvancedProtection.dll
- 基于Java和Shell语言的csj_21_08_20_task1设计源码分享
- 基于Typescript和Python的MNIST卷积神经网络模型加载与预测浏览器端设计源码
- 基于Python的RasaTalk语音对话语义分析系统源码
- 基于Vue框架的租车平台前端设计源码
- 基于Java和C/C++的浙江高速反扫优惠券码830主板设计源码
- 基于Java的一站式退休服务项目源码设计
- 基于Java语言实现的鼎鸿餐厅管理系统设计源码
- 基于Java的iText扩展库:简化PDF创建与中文字体应用设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功