2023-02-23 22:50:30 +00:00
|
|
|
package ipld_eth_statedb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/core/state"
|
2023-02-27 21:51:04 +00:00
|
|
|
"github.com/ethereum/go-ethereum/ethdb"
|
|
|
|
"github.com/ethereum/go-ethereum/trie"
|
2023-02-23 22:50:30 +00:00
|
|
|
"github.com/jackc/pgx/pgxpool"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Database interface {
|
|
|
|
ContractCode(addrHash common.Hash, codeHash common.Hash) ([]byte, error)
|
|
|
|
ContractCodeSize(addrHash common.Hash, codeHash common.Hash) (int, error)
|
|
|
|
OpenTrie(root common.Hash) (state.Trie, error)
|
|
|
|
OpenStorageTrie(addrHash common.Hash, root common.Hash) (state.Trie, error)
|
|
|
|
CopyTrie(trie state.Trie) state.Trie
|
|
|
|
}
|
|
|
|
|
|
|
|
type StateDatabase struct {
|
2023-02-27 21:51:04 +00:00
|
|
|
db pgxpool.Pool
|
|
|
|
trieDB *trie.Database
|
|
|
|
ethDB ethdb.Database
|
2023-02-23 22:50:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (sd *StateDatabase) ContractCode(addrHash common.Hash, codeHash common.Hash) ([]byte, error) {
|
2023-02-27 21:51:04 +00:00
|
|
|
|
2023-02-23 22:50:30 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sd *StateDatabase) ContractCodeSize(addrHash common.Hash, codeHash common.Hash) (int, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sd *StateDatabase) OpenTrie(root common.Hash) (state.Trie, error) {
|
2023-02-27 21:51:04 +00:00
|
|
|
return trie.NewStateTrie(common.Hash{}, root, sd.trieDB), nil
|
2023-02-23 22:50:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (sd *StateDatabase) OpenStorageTrie(addrHash common.Hash, root common.Hash) (state.Trie, error) {
|
|
|
|
panic("replace my usage")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sd *StateDatabase) CopyTrie(trie state.Trie) state.Trie {
|
|
|
|
panic("replace my usage")
|
|
|
|
}
|