private bool Persist <T>(string platform, string chainName, Hash hash, StorageConst type, T data) { var storageKey = type + chainName + hash.ToString(); var keyStore = _keyValueStore[platform + type] as KeyValueStore <string, T>; if (!keyStore.ContainsKey(storageKey)) { keyStore.Set(storageKey, data); return(true); } logger.Error("storageKey " + storageKey + " failed!"); return(false); }
private T Read <T>(string platform, string chainName, Hash hash, StorageConst type) { var storageKey = type + chainName + hash.ToString(); var keyStore = _keyValueStore[platform + type] as KeyValueStore <string, T>; try { if (keyStore.TryGet(storageKey, out T data)) { return(data); } } catch (Exception e) { logger.Error(e.ToString()); return(default(T)); } return(default(T)); }