def addMap(key, value): map1Info = Get(GetContext(), MAPKEY) map1 = Deserialize(map1Info) Notify(["before add, map is ", map1["key1"], map1["key2"]]) map1[key] = value map1.remove("key1") map1Info = Serialize(map1) Put(GetContext(), MAPKEY, map1Info) Notify(["after add, map is ", map1["key2"], map1[key]]) return True
def del_ont_item(ont_id, ipfs_hash): if not CheckWitness(ont_id): return False item_key = concat_key(ITEM_PREFIX, ont_id) item_list_info = Get(ctx, item_key) item_list = [] if item_list_info: item_list = Deserialize(item_list_info) for item in item_list: if item[0] == ipfs_hash: item_list.remove(item) itemRemove(ipfs_hash) return True itemRemoveFail(ipfs_hash) return True
def del_ont_item(ont_id, ipfs_hash): if not CheckWitness(ont_id): return False item_key = concat_key(ITEM_PREFIX, ont_id) item_list_info = Get(ctx, item_key) item_list = [] if item_list_info: item_list = Deserialize(item_list_info) for i in range(0, len(item_list)): if item_list[i][0] == ipfs_hash: item_list.remove(i) item_list_info = Serialize(item_list) Put(ctx, item_key, item_list_info) itemRemove(ipfs_hash) return True itemRemoveFail(ipfs_hash) return True