def storage_put(self, config: Config, engine: ExecutionEngine): print("*********storage_put:") item = PushData.pop_interop_interface(engine) key = PushData.pop_bytearray(engine) value = PushData.pop_bytearray(engine) storage_map = config.get_storage_map() storage_map[item.value.hex() + key.hex()] = value.hex() date = time.strftime('%Y-%m-%d', time.localtime(time.time())) with open(date + '.json', "w") as f: json.dump(storage_map, f, default=lambda obj: dict(obj), indent=4)
def storage_get(self, config: Config, engine: ExecutionEngine): if len(engine.evaluation_stack.e) < 2: raise RuntimeError("evaluation stack size less than 2") item = PushData.pop_interop_interface(engine) key = PushData.pop_bytearray(engine) storage_map = config.get_storage_map() value = bytearray() if len(storage_map) != 0: temp = storage_map.get(item.value.hex() + key.hex(), '') value = bytearray.fromhex(temp) if value is None or value == '': value = bytearray() PushData.push_data(engine, value)