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
评论列表
文章目录