-
Notifications
You must be signed in to change notification settings - Fork 199
/
trieStorageManagerWithoutPruning.go
42 lines (34 loc) · 1.22 KB
/
trieStorageManagerWithoutPruning.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package trie
import (
"fmt"
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go/common"
)
// trieStorageManagerWithoutPruning manages the storage operations of the trie, but does not prune old values
type trieStorageManagerWithoutPruning struct {
common.StorageManager
storage storageManagerExtension
}
// NewTrieStorageManagerWithoutPruning creates a new instance of trieStorageManagerWithoutPruning
func NewTrieStorageManagerWithoutPruning(sm common.StorageManager) (*trieStorageManagerWithoutPruning, error) {
if check.IfNil(sm) {
return nil, ErrNilTrieStorage
}
tsm, ok := sm.GetBaseTrieStorageManager().(storageManagerExtension)
if !ok {
return nil, fmt.Errorf("invalid storage manager type %T", sm.GetBaseTrieStorageManager())
}
return &trieStorageManagerWithoutPruning{
StorageManager: sm,
storage: tsm,
}, nil
}
// IsPruningEnabled returns false if the trie pruning is disabled
func (tsm *trieStorageManagerWithoutPruning) IsPruningEnabled() bool {
return false
}
// Remove deletes the given hash from checkpointHashesHolder
func (tsm *trieStorageManagerWithoutPruning) Remove(hash []byte) error {
tsm.storage.RemoveFromCheckpointHashesHolder(hash)
return nil
}