From 3a5606673ab4661fa1f0d08f3d3bf2793069d640 Mon Sep 17 00:00:00 2001 From: i-norden Date: Mon, 6 Mar 2023 11:46:07 -0600 Subject: [PATCH] removeu unused method hash arg --- database.go | 10 +++++----- state_object.go | 4 ++-- statedb_test.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/database.go b/database.go index 48a7d49..db94cfb 100644 --- a/database.go +++ b/database.go @@ -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 } diff --git a/state_object.go b/state_object.go index a28c8bc..df2aa90 100644 --- a/state_object.go +++ b/state_object.go @@ -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)) } diff --git a/statedb_test.go b/statedb_test.go index 6053286..644586c 100644 --- a/statedb_test.go +++ b/statedb_test.go @@ -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)