Esempio n. 1
0
        public bool GetStateProof(UInt256 root, StorageKey skey, out HashSet <byte[]> proof)
        {
            var trieReadOnlyDb = new TrieReadOnlyStore(Store, Prefixes.DATA_MPT);
            var readOnlyTrie   = new MPTReadOnlyTrie(root, trieReadOnlyDb);

            return(readOnlyTrie.GetProof(skey.ToArray(), out proof));
        }
Esempio n. 2
0
        private void PersistLocalStateRoot()
        {
            using (Snapshot snapshot = GetSnapshot())
            {
                var trieDb       = new TrieReadOnlyStore(Store, Prefixes.DATA_MPT);
                var currentRoot  = trieDb.GetRoot();
                var currentIndex = snapshot.Height;
                var preHash      = UInt256.Zero;
                if (currentIndex > 0)
                {
                    var last_state_root = currentSnapshot.StateRoots.TryGet(currentIndex - 1);
                    preHash = last_state_root.StateRoot.Hash;
                }
                var stateRootState = new StateRootState
                {
                    Flag      = StateRootVerifyFlag.Unverified,
                    StateRoot = new StateRoot
                    {
                        Version = MPTTrie.Version,
                        Index   = currentIndex,
                        PreHash = preHash,
                        Root    = currentRoot,
                    }
                };

                snapshot.StateRoots.Add(currentIndex, stateRootState);
                snapshot.Commit();
            }
        }