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


Python Contract.blockchain方法代码示例

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


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

示例1: check_for_payment

# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import blockchain [as 别名]
    def check_for_payment(self, request):
        if not self.protocol.blockchain.connected:
            request.write(json.dumps({"success": False, "reason": "libbitcoin server offline"}, indent=4))
            request.finish()
            return server.NOT_DONE_YET
        try:
            file_path = DATA_FOLDER + "purchases/unfunded/" + request.args["order_id"][0] + ".json"
            with open(file_path, 'r') as filename:
                order = json.load(filename, object_pairs_hook=OrderedDict)
            c = Contract(self.db, contract=order, testnet=self.protocol.testnet)
            self.protocol.blockchain.refresh_connection()
            c.blockchain = self.protocol.blockchain
            c.notification_listener = self.mserver.protocol.get_notification_listener()
            c.is_purchase = True
            addr = c.contract["buyer_order"]["order"]["payment"]["address"]

            def history_fetched(ec, history):
                if not ec:
                    # pylint: disable=W0612
                    # pylint: disable=W0640
                    for objid, txhash, index, height, value in history:
                        def cb_txpool(ec, result):
                            if ec:
                                self.protocol.blockchain.fetch_transaction(txhash, cb_chain)
                            else:
                                c.on_tx_received(None, None, None, None, result)

                        def cb_chain(ec, result):
                            if not ec:
                                c.on_tx_received(None, None, None, None, result)

                        self.protocol.blockchain.fetch_txpool_transaction(txhash, cb_txpool)

            self.protocol.blockchain.fetch_history2(addr, history_fetched)

            request.write(json.dumps({"success": True}, indent=4))
            request.finish()
            return server.NOT_DONE_YET
        except Exception, e:
            request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
            request.finish()
            return server.NOT_DONE_YET
开发者ID:syntox,项目名称:OpenBazaar-Server,代码行数:44,代码来源:restapi.py


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