mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 11:46:44 +00:00
core/state: fix
This commit is contained in:
parent
db6f23d1e0
commit
a97c08dedb
3 changed files with 6 additions and 3 deletions
|
|
@ -201,7 +201,6 @@ func (r *cachingCodeReader) Code(addr common.Address, codeHash common.Hash) ([]b
|
||||||
func (r *cachingCodeReader) CodeSize(addr common.Address, codeHash common.Hash) (int, error) {
|
func (r *cachingCodeReader) CodeSize(addr common.Address, codeHash common.Hash) (int, error) {
|
||||||
if cached, ok := r.codeSizeCache.Get(codeHash); ok {
|
if cached, ok := r.codeSizeCache.Get(codeHash); ok {
|
||||||
r.hit.Add(1)
|
r.hit.Add(1)
|
||||||
r.hitBytes.Add(int64(cached))
|
|
||||||
return cached, nil
|
return cached, nil
|
||||||
}
|
}
|
||||||
code, err := r.Code(addr, codeHash)
|
code, err := r.Code(addr, codeHash)
|
||||||
|
|
|
||||||
|
|
@ -568,7 +568,6 @@ func (s *stateObject) CodeSize() int {
|
||||||
defer func(start time.Time) {
|
defer func(start time.Time) {
|
||||||
s.db.CodeLoaded += 1
|
s.db.CodeLoaded += 1
|
||||||
s.db.CodeReads += time.Since(start)
|
s.db.CodeReads += time.Since(start)
|
||||||
s.db.CodeLoadBytes += len(s.code)
|
|
||||||
}(time.Now())
|
}(time.Now())
|
||||||
|
|
||||||
size, err := s.db.reader.CodeSize(s.address, common.BytesToHash(s.CodeHash()))
|
size, err := s.db.reader.CodeSize(s.address, common.BytesToHash(s.CodeHash()))
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,12 @@ type StateDB struct {
|
||||||
StorageUpdated atomic.Int64 // Number of storage slots updated during the state transition
|
StorageUpdated atomic.Int64 // Number of storage slots updated during the state transition
|
||||||
StorageDeleted atomic.Int64 // Number of storage slots deleted during the state transition
|
StorageDeleted atomic.Int64 // Number of storage slots deleted during the state transition
|
||||||
CodeLoaded int // Number of contract code loaded during the state transition
|
CodeLoaded int // Number of contract code loaded during the state transition
|
||||||
CodeLoadBytes int // Total number of bytes read from contract code
|
|
||||||
|
// CodeLoadBytes is the total number of bytes read from contract code.
|
||||||
|
// This value may be smaller than the actual number of bytes read, since
|
||||||
|
// some APIs (e.g. CodeSize) may load the entire code from either the
|
||||||
|
// cache or the database when the size is not available in the cache.
|
||||||
|
CodeLoadBytes int
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new state from a given trie.
|
// New creates a new state from a given trie.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue