mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 08:53:46 +00:00
Merge branch 'ethereum:master' into portal
This commit is contained in:
commit
346440e510
5 changed files with 14 additions and 17 deletions
|
|
@ -54,7 +54,7 @@ func NewHexOrDecimal256(x int64) *HexOrDecimal256 {
|
||||||
// It is similar to UnmarshalText, but allows parsing real decimals too, not just
|
// It is similar to UnmarshalText, but allows parsing real decimals too, not just
|
||||||
// quoted decimal strings.
|
// quoted decimal strings.
|
||||||
func (i *HexOrDecimal256) UnmarshalJSON(input []byte) error {
|
func (i *HexOrDecimal256) UnmarshalJSON(input []byte) error {
|
||||||
if len(input) > 0 && input[0] == '"' {
|
if len(input) > 1 && input[0] == '"' {
|
||||||
input = input[1 : len(input)-1]
|
input = input[1 : len(input)-1]
|
||||||
}
|
}
|
||||||
return i.UnmarshalText(input)
|
return i.UnmarshalText(input)
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ type HexOrDecimal64 uint64
|
||||||
// It is similar to UnmarshalText, but allows parsing real decimals too, not just
|
// It is similar to UnmarshalText, but allows parsing real decimals too, not just
|
||||||
// quoted decimal strings.
|
// quoted decimal strings.
|
||||||
func (i *HexOrDecimal64) UnmarshalJSON(input []byte) error {
|
func (i *HexOrDecimal64) UnmarshalJSON(input []byte) error {
|
||||||
if len(input) > 0 && input[0] == '"' {
|
if len(input) > 1 && input[0] == '"' {
|
||||||
input = input[1 : len(input)-1]
|
input = input[1 : len(input)-1]
|
||||||
}
|
}
|
||||||
return i.UnmarshalText(input)
|
return i.UnmarshalText(input)
|
||||||
|
|
|
||||||
|
|
@ -666,6 +666,9 @@ func diffToDisk(bottom *diffLayer) *diskLayer {
|
||||||
|
|
||||||
// Release releases resources
|
// Release releases resources
|
||||||
func (t *Tree) Release() {
|
func (t *Tree) Release() {
|
||||||
|
t.lock.RLock()
|
||||||
|
defer t.lock.RUnlock()
|
||||||
|
|
||||||
if dl := t.disklayer(); dl != nil {
|
if dl := t.disklayer(); dl != nil {
|
||||||
dl.Release()
|
dl.Release()
|
||||||
}
|
}
|
||||||
|
|
@ -850,8 +853,8 @@ func (t *Tree) diskRoot() common.Hash {
|
||||||
// generating is an internal helper function which reports whether the snapshot
|
// generating is an internal helper function which reports whether the snapshot
|
||||||
// is still under the construction.
|
// is still under the construction.
|
||||||
func (t *Tree) generating() (bool, error) {
|
func (t *Tree) generating() (bool, error) {
|
||||||
t.lock.Lock()
|
t.lock.RLock()
|
||||||
defer t.lock.Unlock()
|
defer t.lock.RUnlock()
|
||||||
|
|
||||||
layer := t.disklayer()
|
layer := t.disklayer()
|
||||||
if layer == nil {
|
if layer == nil {
|
||||||
|
|
@ -864,8 +867,8 @@ func (t *Tree) generating() (bool, error) {
|
||||||
|
|
||||||
// DiskRoot is an external helper function to return the disk layer root.
|
// DiskRoot is an external helper function to return the disk layer root.
|
||||||
func (t *Tree) DiskRoot() common.Hash {
|
func (t *Tree) DiskRoot() common.Hash {
|
||||||
t.lock.Lock()
|
t.lock.RLock()
|
||||||
defer t.lock.Unlock()
|
defer t.lock.RUnlock()
|
||||||
|
|
||||||
return t.diskRoot()
|
return t.diskRoot()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/trie/triestate"
|
"github.com/ethereum/go-ethereum/trie/triestate"
|
||||||
|
"golang.org/x/exp/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
// State history records the state changes involved in executing a block. The
|
// State history records the state changes involved in executing a block. The
|
||||||
|
|
@ -244,19 +245,13 @@ type history struct {
|
||||||
// newHistory constructs the state history object with provided state change set.
|
// newHistory constructs the state history object with provided state change set.
|
||||||
func newHistory(root common.Hash, parent common.Hash, block uint64, states *triestate.Set) *history {
|
func newHistory(root common.Hash, parent common.Hash, block uint64, states *triestate.Set) *history {
|
||||||
var (
|
var (
|
||||||
accountList []common.Address
|
accountList = maps.Keys(states.Accounts)
|
||||||
storageList = make(map[common.Address][]common.Hash)
|
storageList = make(map[common.Address][]common.Hash)
|
||||||
)
|
)
|
||||||
for addr := range states.Accounts {
|
|
||||||
accountList = append(accountList, addr)
|
|
||||||
}
|
|
||||||
slices.SortFunc(accountList, common.Address.Cmp)
|
slices.SortFunc(accountList, common.Address.Cmp)
|
||||||
|
|
||||||
for addr, slots := range states.Storages {
|
for addr, slots := range states.Storages {
|
||||||
slist := make([]common.Hash, 0, len(slots))
|
slist := maps.Keys(slots)
|
||||||
for slotHash := range slots {
|
|
||||||
slist = append(slist, slotHash)
|
|
||||||
}
|
|
||||||
slices.SortFunc(slist, common.Hash.Cmp)
|
slices.SortFunc(slist, common.Hash.Cmp)
|
||||||
storageList[addr] = slist
|
storageList[addr] = slist
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package pathdb
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/fastcache"
|
"github.com/VictoriaMetrics/fastcache"
|
||||||
|
|
@ -90,12 +91,10 @@ func (b *nodebuffer) commit(nodes map[common.Hash]map[string]*trienode.Node) *no
|
||||||
// The nodes belong to original diff layer are still accessible even
|
// The nodes belong to original diff layer are still accessible even
|
||||||
// after merging, thus the ownership of nodes map should still belong
|
// after merging, thus the ownership of nodes map should still belong
|
||||||
// to original layer and any mutation on it should be prevented.
|
// to original layer and any mutation on it should be prevented.
|
||||||
current = make(map[string]*trienode.Node, len(subset))
|
|
||||||
for path, n := range subset {
|
for path, n := range subset {
|
||||||
current[path] = n
|
|
||||||
delta += int64(len(n.Blob) + len(path))
|
delta += int64(len(n.Blob) + len(path))
|
||||||
}
|
}
|
||||||
b.nodes[owner] = current
|
b.nodes[owner] = maps.Clone(subset)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for path, n := range subset {
|
for path, n := range subset {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue