smart_contracts.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:dragonchain 作者: dragonchain 项目源码 文件源码
def _sc_provisioning_helper(self, pl, sc_class, sc_key):
        """
        insert sc code into appropriate dictionary
        :param pl: transaction payload to extract sc from
        :param sc_class: type of sc being dealt with (e.g. tsc, ssc, etc.)
        :param sc_key: transaction type
        """
        try:
            if 'smart_contract' in pl:
                sc = pl['smart_contract']
                sc_impl = sc[sc_class]
                if sc_impl:
                    try:
                        sc_impl = base64.standard_b64decode(sc_impl)
                    except TypeError:
                        raise Exception("The Smart Contract implementation for " + str(sc_key) +
                                        " must be base64 encoded.")

                    func = None
                    # define sc function
                    exec(sc_impl)
                    # store sc function for this txn type (sc_key)
                    self.sc_container[sc_class][sc_key] = func
                else:
                    logger().warning("No smart contract code provided...")
                    return False
            else:
                return False
        except Exception as ex:
            template = "An exception of type {0} occurred. Arguments:\n{1!r}"
            message = template.format(type(ex).__name__, ex.args)
            logger().warning(message)
            return False
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号