Extract loading config to a shared file

This commit is contained in:
Eric Meyer
2017-11-09 13:37:10 -06:00
parent c0f737868b
commit 84205a21ea
4 changed files with 27 additions and 27 deletions
+4 -8
View File
@@ -2,11 +2,10 @@ package main
import (
"flag"
"log"
"fmt"
"github.com/8thlight/vulcanizedb/pkg/config"
"github.com/8thlight/vulcanizedb/cmd"
"github.com/8thlight/vulcanizedb/pkg/geth"
"github.com/8thlight/vulcanizedb/pkg/history"
"github.com/8thlight/vulcanizedb/pkg/repositories"
@@ -16,13 +15,10 @@ func main() {
environment := flag.String("environment", "", "Environment name")
startingBlockNumber := flag.Int("starting-number", -1, "First block to fill from")
flag.Parse()
cfg, err := config.NewConfig(*environment)
if err != nil {
log.Fatalf("Error loading config\n%v", err)
}
config := cmd.LoadConfig(*environment)
blockchain := geth.NewGethBlockchain(cfg.Client.IPCPath)
repository := repositories.NewPostgres(cfg.Database)
blockchain := geth.NewGethBlockchain(config.Client.IPCPath)
repository := repositories.NewPostgres(config.Database)
numberOfBlocksCreated := history.PopulateBlocks(blockchain, repository, int64(*startingBlockNumber))
fmt.Printf("Populated %d blocks", numberOfBlocksCreated)
}