Refactor postgres to be initialized with config
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/8thlight/vulcanizedb/pkg/geth"
|
||||
"github.com/8thlight/vulcanizedb/pkg/history"
|
||||
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -23,12 +22,7 @@ func main() {
|
||||
}
|
||||
|
||||
blockchain := geth.NewGethBlockchain(cfg.Client.IPCPath)
|
||||
connectString := config.DbConnectionString(cfg.Database)
|
||||
db, err := sqlx.Connect("postgres", connectString)
|
||||
if err != nil {
|
||||
log.Fatalf("Error connecting to DB: %v\n", err)
|
||||
}
|
||||
repository := repositories.NewPostgres(db)
|
||||
repository := repositories.NewPostgres(cfg.Database)
|
||||
numberOfBlocksCreated := history.PopulateBlocks(blockchain, repository, int64(*startingBlockNumber))
|
||||
fmt.Printf("Populated %d blocks", numberOfBlocksCreated)
|
||||
}
|
||||
|
||||
+1
-7
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/8thlight/vulcanizedb/pkg/geth"
|
||||
"github.com/8thlight/vulcanizedb/pkg/observers"
|
||||
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -26,12 +25,7 @@ func main() {
|
||||
fmt.Println("Client Path ", cfg.Client.IPCPath)
|
||||
blockchain := geth.NewGethBlockchain(cfg.Client.IPCPath)
|
||||
loggingObserver := observers.BlockchainLoggingObserver{}
|
||||
connectString := config.DbConnectionString(cfg.Database)
|
||||
db, err := sqlx.Connect("postgres", connectString)
|
||||
if err != nil {
|
||||
log.Fatalf("Error connecting to DB: %v\n", err)
|
||||
}
|
||||
repository := repositories.NewPostgres(db)
|
||||
repository := repositories.NewPostgres(cfg.Database)
|
||||
dbObserver := observers.NewBlockchainDbObserver(repository)
|
||||
listener := blockchain_listener.NewBlockchainListener(blockchain, []core.BlockchainObserver{
|
||||
loggingObserver,
|
||||
|
||||
Reference in New Issue
Block a user