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
|
// be created with new root and updated trie database for following usage
|
||||||
Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet, error)
|
Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet, error)
|
||||||
|
|
||||||
// CommitAndObtainAccessList does the same thing as Commit and returns an
|
// AccessList returns a map of path->blob containing all trie nodes that have
|
||||||
// access list map of trie nodes read from the database.
|
// been accessed.
|
||||||
CommitAndObtainAccessList(collectLeaf bool) (common.Hash, *trienode.NodeSet, map[string][]byte, error)
|
|
||||||
|
|
||||||
// AccessList returns a map of trie node read from the database.
|
|
||||||
AccessList() map[string][]byte
|
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
|
// 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
|
// starts at the key after the given start key. And error will be returned
|
||||||
// if fails to create node iterator.
|
// if fails to create node iterator.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha256"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
|
@ -317,16 +316,6 @@ func (w *Witness) PrettyPrint() string {
|
||||||
return b.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.
|
// NewWitness returns a new witness object.
|
||||||
func NewWitness(root common.Hash) *Witness {
|
func NewWitness(root common.Hash) *Witness {
|
||||||
return &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
|
// Finalise all the dirty storage states and write them into the tries
|
||||||
s.Finalise(deleteEmptyObjects)
|
s.Finalise(deleteEmptyObjects)
|
||||||
|
|
||||||
// If there was a trie prefetcher operating, it gets aborted and irrevocably
|
// If there was a trie prefetcher operating, it gets aborted and irrevocably
|
||||||
// modified after we start retrieving tries. Remove it from the statedb after
|
// modified after we start retrieving tries. Remove it from the statedb after
|
||||||
// this round of use.
|
// this round of use.
|
||||||
//
|
//
|
||||||
// This is weird pre-byzantium since the first tx runs with a prefetcher and
|
// 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
|
// the remainder without, but pre-byzantium even the initial prefetcher is
|
||||||
// useless, so no sleep lost.
|
// useless, so no sleep lost.
|
||||||
prefetcher := s.prefetcher
|
prefetcher := s.prefetcher
|
||||||
if s.prefetcher != nil {
|
if s.prefetcher != nil {
|
||||||
defer func() {
|
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.storagesOrigin = make(map[common.Address]map[common.Hash][]byte)
|
||||||
s.stateObjectsDirty = make(map[common.Address]struct{})
|
s.stateObjectsDirty = make(map[common.Address]struct{})
|
||||||
s.stateObjectsDestruct = make(map[common.Address]*types.StateAccount)
|
s.stateObjectsDestruct = make(map[common.Address]*types.StateAccount)
|
||||||
|
|
||||||
return root, nil
|
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.
|
// Body returns the non-header content of the block.
|
||||||
// Note the returned data is not an independent copy.
|
// Note the returned data is not an independent copy.
|
||||||
func (b *Block) Body() *Body {
|
func (b *Block) Body() *Body {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue