Skip to content

Commit

Permalink
Remove storage state syncing field
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jan 17, 2022
1 parent cf4e9ee commit 1461a0a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 32 deletions.
15 changes: 0 additions & 15 deletions dot/state/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type StorageState struct {
changedLock sync.RWMutex
observerList []Observer
pruner pruner.Pruner
syncing bool
}

// NewStorageState creates a new StorageState backed by the given trie and database located at basePath.
Expand Down Expand Up @@ -78,11 +77,6 @@ func NewStorageState(db chaindb.Database, blockState *BlockState,
}, nil
}

// SetSyncing sets whether the node is currently syncing or not
func (s *StorageState) SetSyncing(syncing bool) {
s.syncing = syncing
}

func (s *StorageState) pruneKey(keyHeader *types.Header) {
s.tries.Delete(keyHeader.StateRoot)
}
Expand All @@ -91,15 +85,6 @@ func (s *StorageState) pruneKey(keyHeader *types.Header) {
func (s *StorageState) StoreTrie(ts *rtstorage.TrieState, header *types.Header) error {
root := ts.MustRoot()

if s.syncing {
// keep only the trie at the head of the chain when syncing
// TODO: probably remove this when memory usage improves (#1494)
s.tries.Range(func(k, _ interface{}) bool {
s.tries.Delete(k)
return true
})
}

_, _ = s.tries.LoadOrStore(root, ts.Trie())

if _, ok := s.pruner.(*pruner.FullNode); header == nil && ok {
Expand Down
16 changes: 0 additions & 16 deletions dot/state/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,6 @@ func syncMapLen(m *sync.Map) int {
return l
}

func TestStorage_StoreTrie_Syncing(t *testing.T) {
storage := newTestStorageState(t)
ts, err := storage.TrieState(&trie.EmptyHash)
require.NoError(t, err)

key := []byte("testkey")
value := []byte("testvalue")
ts.Set(key, value)

storage.SetSyncing(true)
err = storage.StoreTrie(ts, nil)
require.NoError(t, err)
require.Equal(t, 1, syncMapLen(storage.tries))
}

func TestStorage_StoreTrie_NotSyncing(t *testing.T) {
storage := newTestStorageState(t)
ts, err := storage.TrieState(&trie.EmptyHash)
Expand All @@ -183,7 +168,6 @@ func TestStorage_StoreTrie_NotSyncing(t *testing.T) {
value := []byte("testvalue")
ts.Set(key, value)

storage.SetSyncing(false)
err = storage.StoreTrie(ts, nil)
require.NoError(t, err)
require.Equal(t, 2, syncMapLen(storage.tries))
Expand Down
1 change: 0 additions & 1 deletion dot/sync/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type BlockState interface {
type StorageState interface {
TrieState(root *common.Hash) (*rtstorage.TrieState, error)
LoadCodeHash(*common.Hash) (common.Hash, error)
SetSyncing(bool)
sync.Locker
}

Expand Down

0 comments on commit 1461a0a

Please sign in to comment.