public static ITrie Commit(
            this IStateStore stateStore,
            HashDigest <SHA256>?previousStateRootHash,
            IImmutableDictionary <string, IValue> rawStatesDelta,
            bool rehearsal = false
            )
        {
            ITrie trie = stateStore.GetStateRoot(previousStateRootHash);

            foreach (KeyValuePair <string, IValue> pair in rawStatesDelta)
            {
                byte[] keyBytes = KeyEncoding.GetBytes(pair.Key);
                trie = trie.Set(keyBytes, pair.Value);
            }

            ITrie stage = trie.Commit(rehearsal);

            return(rehearsal ? stage : stateStore.GetStateRoot(stage.Hash));
        }
        public static IValue?GetState(
            this IStateStore stateStore,
            string rawStateKey,
            HashDigest <SHA256>?stateRootHash
            )
        {
            byte[] keyBytes = KeyEncoding.GetBytes(rawStateKey);
            ITrie  trie     = stateStore.GetStateRoot(stateRootHash);

            return(trie.TryGet(keyBytes, out IValue? value) ? value : null);
        }
示例#3
0
 public ITrie GetStateRoot(HashDigest <SHA256>?stateRootHash)
 {
     Log(nameof(GetStateRoot), stateRootHash);
     return(_stateStore.GetStateRoot(stateRootHash));
 }
 public static bool ContainsStateRoot(
     this IStateStore stateStore,
     HashDigest <SHA256> stateRootHash
     ) =>
 stateStore.GetStateRoot(stateRootHash).Recorded;