mpt: add the notion of MPT mode
It directly affects the storage format, so it's important. ModeGC is not used at the moment, but defined for future extensibility.
This commit is contained in:
parent
de99c3acdb
commit
86cb4ed80f
13 changed files with 140 additions and 96 deletions
|
@ -221,7 +221,11 @@ func (s *Module) defineSyncStage() error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to get header to initialize MPT billet: %w", err)
|
||||
}
|
||||
s.billet = mpt.NewBillet(header.PrevStateRoot, s.bc.GetConfig().KeepOnlyLatestState,
|
||||
var mode mpt.TrieMode
|
||||
if s.bc.GetConfig().KeepOnlyLatestState {
|
||||
mode |= mpt.ModeLatest
|
||||
}
|
||||
s.billet = mpt.NewBillet(header.PrevStateRoot, mode,
|
||||
TemporaryPrefix(s.dao.Version.StoragePrefix), s.dao.Store)
|
||||
s.log.Info("MPT billet initialized",
|
||||
zap.Uint32("height", s.syncPoint),
|
||||
|
@ -494,7 +498,11 @@ func (s *Module) Traverse(root util.Uint256, process func(node mpt.Node, nodeByt
|
|||
s.lock.RLock()
|
||||
defer s.lock.RUnlock()
|
||||
|
||||
b := mpt.NewBillet(root, s.bc.GetConfig().KeepOnlyLatestState, 0, storage.NewMemCachedStore(s.dao.Store))
|
||||
var mode mpt.TrieMode
|
||||
if s.bc.GetConfig().KeepOnlyLatestState {
|
||||
mode |= mpt.ModeLatest
|
||||
}
|
||||
b := mpt.NewBillet(root, mode, 0, storage.NewMemCachedStore(s.dao.Store))
|
||||
return b.Traverse(func(pathToNode []byte, node mpt.Node, nodeBytes []byte) bool {
|
||||
return process(node, nodeBytes)
|
||||
}, false)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue