Example #1
0
        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);
        }
Example #2
0
        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));
        }