mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
more
This commit is contained in:
parent
d6d48f3713
commit
3a121ee65e
4 changed files with 25 additions and 24 deletions
|
|
@ -126,13 +126,14 @@ type Trie interface {
|
|||
// be created with new root and updated trie database for following usage
|
||||
Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet, error)
|
||||
|
||||
// CommitAndObtainAccessList does the same thing as Commit and returns an
|
||||
// access list map of trie nodes read from the database.
|
||||
CommitAndObtainAccessList(collectLeaf bool) (common.Hash, *trienode.NodeSet, map[string][]byte, error)
|
||||
|
||||
// AccessList returns a map of trie node read from the database.
|
||||
// AccessList returns a map of path->blob containing all trie nodes that have
|
||||
// been accessed.
|
||||
AccessList() map[string][]byte
|
||||
|
||||
// CommitAndObtainAccessList does the same thing as Commit, but also returns
|
||||
// the access list of the trie.
|
||||
CommitAndObtainAccessList(collectLeaf bool) (common.Hash, *trienode.NodeSet, map[string][]byte, error)
|
||||
|
||||
// NodeIterator returns an iterator that returns nodes of the trie. Iteration
|
||||
// starts at the key after the given start key. And error will be returned
|
||||
// if fails to create node iterator.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package state
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
|
|
@ -317,16 +316,6 @@ func (w *Witness) PrettyPrint() string {
|
|||
return b.String()
|
||||
}
|
||||
|
||||
// Hash returns the sha256 hash of a witness
|
||||
func (w *Witness) Hash() common.Hash {
|
||||
res, err := rlp.EncodeToBytes(w.sortedWitness())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return common.Hash(sha256.Sum256(res[:]))
|
||||
}
|
||||
|
||||
// NewWitness returns a new witness object.
|
||||
func NewWitness(root common.Hash) *Witness {
|
||||
return &Witness{
|
||||
|
|
|
|||
|
|
@ -918,13 +918,13 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
|
|||
// Finalise all the dirty storage states and write them into the tries
|
||||
s.Finalise(deleteEmptyObjects)
|
||||
|
||||
// If there was a trie prefetcher operating, it gets aborted and irrevocably
|
||||
// modified after we start retrieving tries. Remove it from the statedb after
|
||||
// this round of use.
|
||||
//
|
||||
// This is weird pre-byzantium since the first tx runs with a prefetcher and
|
||||
// the remainder without, but pre-byzantium even the initial prefetcher is
|
||||
// useless, so no sleep lost.
|
||||
// If there was a trie prefetcher operating, it gets aborted and irrevocably
|
||||
// modified after we start retrieving tries. Remove it from the statedb after
|
||||
// this round of use.
|
||||
//
|
||||
// This is weird pre-byzantium since the first tx runs with a prefetcher and
|
||||
// the remainder without, but pre-byzantium even the initial prefetcher is
|
||||
// useless, so no sleep lost.
|
||||
prefetcher := s.prefetcher
|
||||
if s.prefetcher != nil {
|
||||
defer func() {
|
||||
|
|
@ -1412,7 +1412,6 @@ func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, er
|
|||
s.storagesOrigin = make(map[common.Address]map[common.Hash][]byte)
|
||||
s.stateObjectsDirty = make(map[common.Address]struct{})
|
||||
s.stateObjectsDestruct = make(map[common.Address]*types.StateAccount)
|
||||
|
||||
return root, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -329,6 +329,18 @@ func (b *Block) EncodeRLP(w io.Writer) error {
|
|||
})
|
||||
}
|
||||
|
||||
// EncodeRLPWithZeroRoot encodes a block (with header state root set to 0x00...0) to RLP
|
||||
func (b *Block) EncodeRLPWithZeroRoot(w io.Writer) error {
|
||||
old := b.header.Root
|
||||
b.header.Root = common.Hash{}
|
||||
err := b.EncodeRLP(w)
|
||||
b.header.Root = old
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Body returns the non-header content of the block.
|
||||
// Note the returned data is not an independent copy.
|
||||
func (b *Block) Body() *Body {
|
||||
|
|
|
|||
Loading…
Reference in a new issue