diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-26 06:09:38 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-26 06:09:38 +0800 |
commit | 3ebd7f1166f03f94117651d8e74b9603ee7d6966 (patch) | |
tree | 0b26904388619e1e36380a8a21d65476a9f0cc94 /ethchain/state.go | |
parent | 81ef40010f6f31bc94f654048b41fa3a9f9e07eb (diff) | |
download | go-tangerine-3ebd7f1166f03f94117651d8e74b9603ee7d6966.tar go-tangerine-3ebd7f1166f03f94117651d8e74b9603ee7d6966.tar.gz go-tangerine-3ebd7f1166f03f94117651d8e74b9603ee7d6966.tar.bz2 go-tangerine-3ebd7f1166f03f94117651d8e74b9603ee7d6966.tar.lz go-tangerine-3ebd7f1166f03f94117651d8e74b9603ee7d6966.tar.xz go-tangerine-3ebd7f1166f03f94117651d8e74b9603ee7d6966.tar.zst go-tangerine-3ebd7f1166f03f94117651d8e74b9603ee7d6966.zip |
State snapshotting
Diffstat (limited to 'ethchain/state.go')
-rw-r--r-- | ethchain/state.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/ethchain/state.go b/ethchain/state.go index 6ec6916f4..e209e0e2f 100644 --- a/ethchain/state.go +++ b/ethchain/state.go @@ -99,7 +99,21 @@ func (s *State) Cmp(other *State) bool { } func (s *State) Copy() *State { - return NewState(s.trie.Copy()) + state := NewState(s.trie.Copy()) + for k, subState := range s.states { + state.states[k] = subState.Copy() + } + + return state +} + +func (s *State) Snapshot() *State { + return s.Copy() +} + +func (s *State) Revert(snapshot *State) { + s.trie = snapshot.trie + s.states = snapshot.states } func (s *State) Put(key, object []byte) { |