public void UpdateLocalStateRoot(uint height, List <DataCache.Trackable> change_set) { using StateSnapshot state_snapshot = Singleton.GetSnapshot(); foreach (var item in change_set) { switch (item.State) { case TrackState.Added: state_snapshot.Trie.Put(item.Key, item.Item); break; case TrackState.Changed: state_snapshot.Trie.Put(item.Key, item.Item); break; case TrackState.Deleted: state_snapshot.Trie.Delete(item.Key); break; } } UInt256 root_hash = state_snapshot.Trie.Root.Hash; StateRoot state_root = new StateRoot { Index = height, RootHash = root_hash, Witness = null, }; state_snapshot.AddLocalStateRoot(state_root); state_snapshot.Commit(); UpdateCurrentSnapshot(); CheckValidatedStateRoot(height); }
public void UpdateLocalStateRootSnapshot(uint height, List <DataCache.Trackable> change_set) { _state_snapshot = Singleton.GetSnapshot(); foreach (var item in change_set) { switch (item.State) { case TrackState.Added: _state_snapshot.Trie.Put(item.Key, item.Item); break; case TrackState.Changed: _state_snapshot.Trie.Put(item.Key, item.Item); break; case TrackState.Deleted: _state_snapshot.Trie.Delete(item.Key); break; } } UInt256 root_hash = _state_snapshot.Trie.Root.Hash; StateRoot state_root = new StateRoot { Version = StateRoot.CurrentVersion, Index = height, RootHash = root_hash, Witness = null, }; _state_snapshot.AddLocalStateRoot(state_root); }