removeu unused method hash arg

This commit is contained in:
i-norden 2023-03-06 11:46:07 -06:00
parent d68c12706f
commit 3a5606673a
3 changed files with 9 additions and 9 deletions

View File

@ -32,8 +32,8 @@ var (
// Database interface is a union of the subset of the geth state.Database interface required
// to support the vm.StateDB implementation as well as methods specific to this Postgres based implementation
type Database interface {
ContractCode(addrHash common.Hash, codeHash common.Hash) ([]byte, error)
ContractCodeSize(addrHash common.Hash, codeHash common.Hash) (int, error)
ContractCode(codeHash common.Hash) ([]byte, error)
ContractCodeSize(codeHash common.Hash) (int, error)
StateAccount(addressHash, blockHash common.Hash) (*types.StateAccount, error)
StorageValue(addressHash, slotHash, blockHash common.Hash) ([]byte, error)
}
@ -66,7 +66,7 @@ func NewStateDatabase(ctx context.Context, conf Config) (*stateDatabase, error)
}
// ContractCode satisfies Database, it returns the contract code for a given codehash
func (sd *stateDatabase) ContractCode(_, codeHash common.Hash) ([]byte, error) {
func (sd *stateDatabase) ContractCode(codeHash common.Hash) ([]byte, error) {
if code := sd.codeCache.Get(nil, codeHash.Bytes()); len(code) > 0 {
return code, nil
}
@ -87,11 +87,11 @@ func (sd *stateDatabase) ContractCode(_, codeHash common.Hash) ([]byte, error) {
}
// ContractCodeSize satisfies Database, it returns the length of the code for a provided codehash
func (sd *stateDatabase) ContractCodeSize(_, codeHash common.Hash) (int, error) {
func (sd *stateDatabase) ContractCodeSize(codeHash common.Hash) (int, error) {
if cached, ok := sd.codeSizeCache.Get(codeHash); ok {
return cached.(int), nil
}
code, err := sd.ContractCode(common.Hash{}, codeHash)
code, err := sd.ContractCode(codeHash)
return len(code), err
}

View File

@ -259,7 +259,7 @@ func (s *stateObject) Code(db Database) []byte {
if bytes.Equal(s.CodeHash(), emptyCodeHash) {
return nil
}
code, err := db.ContractCode(s.addrHash, common.BytesToHash(s.CodeHash()))
code, err := db.ContractCode(common.BytesToHash(s.CodeHash()))
if err != nil {
s.setError(fmt.Errorf("can't load code hash %x: %v", s.CodeHash(), err))
}
@ -277,7 +277,7 @@ func (s *stateObject) CodeSize(db Database) int {
if bytes.Equal(s.CodeHash(), emptyCodeHash) {
return 0
}
size, err := db.ContractCodeSize(s.addrHash, common.BytesToHash(s.CodeHash()))
size, err := db.ContractCodeSize(common.BytesToHash(s.CodeHash()))
if err != nil {
s.setError(fmt.Errorf("can't load code size %x: %v", s.CodeHash(), err))
}

View File

@ -96,11 +96,11 @@ func TestSuite(t *testing.T) {
require.NoError(t, err)
t.Run("Database", func(t *testing.T) {
size, err := db.ContractCodeSize(AccountAddress.Hash(), AccountCodeHash)
size, err := db.ContractCodeSize(AccountCodeHash)
require.NoError(t, err)
require.Equal(t, len(AccountCode), size)
code, err := db.ContractCode(AccountAddress.Hash(), AccountCodeHash)
code, err := db.ContractCode(AccountCodeHash)
require.NoError(t, err)
require.Equal(t, AccountCode, code)