split ethdb out of service
This commit is contained in:
parent
1fab8ac1c8
commit
2bb06e0a8d
@ -44,7 +44,12 @@ func stateSnapshot() {
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
snapshotService, err := snapshot.NewSnapshotService(snapConfig.Eth, snapshot.NewPublisher(pgDB))
|
||||
edb, err := snapshot.NewLevelDB(snapConfig.Eth)
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
|
||||
snapshotService, err := snapshot.NewSnapshotService(edb, snapshot.NewPublisher(pgDB))
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ type DBConfig struct {
|
||||
ConnConfig postgres.ConnectionConfig
|
||||
}
|
||||
|
||||
// EthConfig is config parameters for the chain.
|
||||
type EthConfig struct {
|
||||
LevelDBPath string
|
||||
AncientDBPath string
|
||||
|
@ -63,13 +63,14 @@ func NewPostgresDB(con *DBConfig) (*postgres.DB, error) {
|
||||
return pgDB, nil
|
||||
}
|
||||
|
||||
// NewSnapshotService creates Service.
|
||||
func NewSnapshotService(con *EthConfig, pub *Publisher) (*Service, error) {
|
||||
edb, err := rawdb.NewLevelDBDatabaseWithFreezer(con.LevelDBPath, 1024, 256, con.AncientDBPath, "eth-pg-ipfs-state-snapshot", false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
func NewLevelDB(con *EthConfig) (ethdb.Database, error) {
|
||||
return rawdb.NewLevelDBDatabaseWithFreezer(
|
||||
con.LevelDBPath, 1024, 256, con.AncientDBPath, "eth-pg-ipfs-state-snapshot", false,
|
||||
)
|
||||
}
|
||||
|
||||
// NewSnapshotService creates Service.
|
||||
func NewSnapshotService(edb ethdb.Database, pub *Publisher) (*Service, error) {
|
||||
return &Service{
|
||||
ethDB: edb,
|
||||
stateDB: state.NewDatabase(edb),
|
||||
|
@ -9,13 +9,13 @@ import (
|
||||
)
|
||||
|
||||
func testConfig(leveldbpath, ancientdbpath string) *Config {
|
||||
dbParams := postgres.ConnectionParams{}
|
||||
dbParams.Name = "snapshot_test"
|
||||
dbParams.Hostname = "localhost"
|
||||
dbParams.Port = 5432
|
||||
dbParams.User = "tester"
|
||||
dbParams.Password = "test_pw"
|
||||
uri := postgres.DbConnectionString(dbParams)
|
||||
dbParams := postgres.ConnectionParams{
|
||||
Name: "snapshot_test",
|
||||
Hostname: "localhost",
|
||||
Port: 5432,
|
||||
User: "tester",
|
||||
Password: "test_pw",
|
||||
}
|
||||
connconfig := postgres.ConnectionConfig{
|
||||
MaxIdle: 0,
|
||||
MaxLifetime: 0,
|
||||
@ -32,7 +32,7 @@ func testConfig(leveldbpath, ancientdbpath string) *Config {
|
||||
return &Config{
|
||||
DB: &DBConfig{
|
||||
Node: nodeinfo,
|
||||
URI: uri,
|
||||
URI: postgres.DbConnectionString(dbParams),
|
||||
ConnConfig: connconfig,
|
||||
},
|
||||
Eth: &EthConfig{
|
||||
|
Loading…
Reference in New Issue
Block a user