implement database.StorageSlot()
This commit is contained in:
parent
8754278d18
commit
ede0af3c26
13
database.go
13
database.go
@ -3,9 +3,10 @@ package ipld_eth_statedb
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/fastcache"
|
"github.com/VictoriaMetrics/fastcache"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
@ -103,5 +104,13 @@ func (sd *stateDatabase) StateAccount(address common.Address) (*types.StateAccou
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sd *stateDatabase) StorageSlot(addressHash, slotHash common.Hash) ([]byte, error) {
|
func (sd *stateDatabase) StorageSlot(addressHash, slotHash common.Hash) ([]byte, error) {
|
||||||
panic("implement me")
|
res := StorageSlotResult{}
|
||||||
|
if err := sd.pgdb.QueryRow(context.Background(), GetStorageSlot, addressHash.Hex(), slotHash.Hex()).Scan(&res); err != nil {
|
||||||
|
return nil, errNotFound
|
||||||
|
}
|
||||||
|
if res.Removed {
|
||||||
|
// TODO: check expected behavior for deleted/non existing accounts
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return res.Value, nil
|
||||||
}
|
}
|
||||||
|
2
sql.go
2
sql.go
@ -28,7 +28,7 @@ const (
|
|||||||
|
|
||||||
// StorageSlotResult struct for unpacking GetStorageSlot result
|
// StorageSlotResult struct for unpacking GetStorageSlot result
|
||||||
type StorageSlotResult struct {
|
type StorageSlotResult struct {
|
||||||
Value string `db:"val"`
|
Value []byte `db:"val"`
|
||||||
Removed bool `db:"removed"`
|
Removed bool `db:"removed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user