本文整理汇总了Python中btctxstore.BtcTxStore.store方法的典型用法代码示例。如果您正苦于以下问题:Python BtcTxStore.store方法的具体用法?Python BtcTxStore.store怎么用?Python BtcTxStore.store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类btctxstore.BtcTxStore
的用法示例。
在下文中一共展示了BtcTxStore.store方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_block
# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import store [as 别名]
def generate_block(self):
"""Close the current block, and generate a new one."""
try:
last_block = latest_block(self.conn)
last_hash = latest_hash(self.conn)
# Get Merkle Root
self.find_leaves()
self.close()
merkle_root = self.merkle_root()
# Get TXID
blockchain = BtcTxStore()
hexdata = merkle_root
privatekeys = app.config["PRIVATE_KEYS"]
changeaddress = app.config["CHANGE_ADDRESS"]
tx_id = blockchain.store(hexdata, privatekeys, changeaddress)
# Close current block
c = self.conn.cursor()
query1 = "UPDATE block_table SET end_hash=?, closed=?, merkle_root=?, tx_id=? WHERE id=?"
c.execute(query1, (last_hash, True, merkle_root, tx_id, last_block))
# Start new block
query2 = "INSERT INTO block_table (start_hash) VALUES (?)"
c.execute(query2, (last_hash,))
self.conn.commit()
self.conn.close()
return 'Block {0} Built.'.format(last_block)
except LookupError:
return 'Block Empty.'