mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
add a way to cleanup snaps on state
This commit is contained in:
parent
3ef9c7fbe1
commit
6735dde9ed
3 changed files with 16 additions and 3 deletions
|
|
@ -180,6 +180,11 @@ func (s *StateDB) GetWitness() *trienode.Witness {
|
||||||
return s.trie.GetWitness()
|
return s.trie.GetWitness()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *StateDB) CleanSnaps() {
|
||||||
|
s.snaps = nil
|
||||||
|
s.snap = nil
|
||||||
|
}
|
||||||
|
|
||||||
// StartPrefetcher initializes a new trie prefetcher to pull in nodes from the
|
// StartPrefetcher initializes a new trie prefetcher to pull in nodes from the
|
||||||
// state trie concurrently while the state is mutated so that when we reach the
|
// state trie concurrently while the state is mutated so that when we reach the
|
||||||
// commit phase, most of the needed data is already hot.
|
// commit phase, most of the needed data is already hot.
|
||||||
|
|
|
||||||
|
|
@ -972,6 +972,7 @@ func (s *BlockChainAPI) GetRequiredBlockState(ctx context.Context, blockNrOrHash
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
state.CleanSnaps()
|
||||||
s.ProcessBlock(ctx, block, state, vm.Config{})
|
s.ProcessBlock(ctx, block, state, vm.Config{})
|
||||||
return state.GetWitness(), nil
|
return state.GetWitness(), nil
|
||||||
// return s.traceBlock(ctx, block)
|
// return s.traceBlock(ctx, block)
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,20 @@ type Witness struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Witness) MarshalJSON() ([]byte, error) {
|
func (u *Witness) MarshalJSON() ([]byte, error) {
|
||||||
nodes := make(map[string]string)
|
type Node struct {
|
||||||
|
Key string
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
nodes := []Node{}
|
||||||
for key, node := range u.Nodes {
|
for key, node := range u.Nodes {
|
||||||
nodes[key] = hex.EncodeToString(node)
|
nodes = append(nodes, Node{
|
||||||
|
Key: hex.EncodeToString([]byte(key)),
|
||||||
|
Value: hex.EncodeToString(node),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return json.Marshal(&struct {
|
return json.Marshal(&struct {
|
||||||
Owner common.Hash
|
Owner common.Hash
|
||||||
Nodes map[string]string
|
Nodes []Node
|
||||||
}{
|
}{
|
||||||
Owner: u.Owner,
|
Owner: u.Owner,
|
||||||
Nodes: nodes,
|
Nodes: nodes,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue