当前位置: 首页>>代码示例>>Python>>正文


Python Bigchain.generate_keys方法代码示例

本文整理汇总了Python中bigchaindb.Bigchain.generate_keys方法的典型用法代码示例。如果您正苦于以下问题:Python Bigchain.generate_keys方法的具体用法?Python Bigchain.generate_keys怎么用?Python Bigchain.generate_keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bigchaindb.Bigchain的用法示例。


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

示例1: open

# 需要导入模块: from bigchaindb import Bigchain [as 别名]
# 或者: from bigchaindb.Bigchain import generate_keys [as 别名]
# "NET PRICE":  "25" ,
# "PRICE":  "50" ,
# "QUANTITY":  "50000" ,
# "SIDE":  "S" ,
# "TYPE":  "EQ"
# },
# ...]
data = []
with open('data.csv', 'r') as fid:
    reader = csv.DictReader(fid)
    for row in reader:
        data.append(row)

# generate distinct users from the CPTY1 column and assign keys
users = []
for user_name in set([d['CPTY1'] for d in data]):
    sk, vk = b.generate_keys()
    user = users.append(
        {
            'name': user_name,
            'signing_key': sk,
            'verifying_key': vk
        }
    )

# create assets on the blockchain with the payload and assign to the user
for asset in data:
    user = [u for u in users if u['name'] == asset['CPTY1']][0]
    tx = b.create_transaction(b.me, user['verifying_key'], None, 'CREATE', payload=asset)
    tx_signed = b.sign_transaction(tx, b.me_private)
    b.write_transaction(tx_signed)
开发者ID:diminator,项目名称:bigchaindb-trade-logger,代码行数:33,代码来源:main.py

示例2: Bigchain

# 需要导入模块: from bigchaindb import Bigchain [as 别名]
# 或者: from bigchaindb.Bigchain import generate_keys [as 别名]
from bigchaindb import Bigchain
import writeout

b = Bigchain()

# create 7 test users
testuser1_priv, testuser1_pub = b.generate_keys()
writeout.exportData((testuser1_priv, testuser1_pub), "user1")

testuser2_priv, testuser2_pub = b.generate_keys()
writeout.exportData((testuser2_priv, testuser2_pub), "user2")

testuser3_priv, testuser3_pub = b.generate_keys()
writeout.exportData((testuser3_priv, testuser3_pub), "user3")

testuser4_priv, testuser4_pub = b.generate_keys()
writeout.exportData((testuser4_priv, testuser4_pub), "user4")

testuser5_priv, testuser5_pub = b.generate_keys()
writeout.exportData((testuser5_priv, testuser5_pub), "user5")

testuser6_priv, testuser6_pub = b.generate_keys()
writeout.exportData((testuser6_priv, testuser6_pub), "user6")

testuser7_priv, testuser7_pub = b.generate_keys()
writeout.exportData((testuser7_priv, testuser7_pub), "govt")
开发者ID:ChesTaylor,项目名称:csci455,代码行数:28,代码来源:dummyusers.py


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