From 121511f10da225819f00bab5263146e13da00823 Mon Sep 17 00:00:00 2001 From: Eric Meyer Date: Wed, 1 Nov 2017 09:40:04 -0500 Subject: [PATCH] Refactor existing code to use Godo --- .gitignore | 1 + Gododir/main.go | 35 +++++++++++++++++++++++++++++++++++ main.go | 25 ------------------------- 3 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 Gododir/main.go delete mode 100644 main.go diff --git a/.gitignore b/.gitignore index e7405fee..8bfa0dbc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea +Gododir/godobin-* test_data_dir/ vendor/ diff --git a/Gododir/main.go b/Gododir/main.go new file mode 100644 index 00000000..21f35193 --- /dev/null +++ b/Gododir/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "log" + + "github.com/8thlight/vulcanizedb/core" + "github.com/jmoiron/sqlx" + do "gopkg.in/godo.v2" +) + +func tasks(p *do.Project) { + + p.Task("run", nil, func(context *do.Context) { + ipcPath := context.Args.MayString("", "ipc-path", "i") + + port := "5432" + host := "localhost" + databaseName := "vulcanize" + + var blockchain core.Blockchain = core.NewGethBlockchain(ipcPath) + blockchain.RegisterObserver(core.BlockchainLoggingObserver{}) + pgConfig := "host=" + host + " port=" + port + " dbname=" + databaseName + " sslmode=disable" + db, err := sqlx.Connect("postgres", pgConfig) + if err != nil { + log.Fatalf("Error connecting to DB: %v\n", err) + } + blockchain.RegisterObserver(core.BlockchainDBObserver{Db: db}) + blockchain.SubscribeToEvents() + }) + +} + +func main() { + do.Godo(tasks) +} diff --git a/main.go b/main.go deleted file mode 100644 index 133480f3..00000000 --- a/main.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "flag" - - "log" - - "github.com/8thlight/vulcanizedb/core" - "github.com/jmoiron/sqlx" -) - -func main() { - ipcPath := flag.String("ipcPath", "", "location geth.ipc") - flag.Parse() - - var blockchain core.Blockchain = core.NewGethBlockchain(*ipcPath) - blockchain.RegisterObserver(core.BlockchainLoggingObserver{}) - pgConfig := "host=localhost port=5432 dbname=vulcanize sslmode=disable" - db, err := sqlx.Connect("postgres", pgConfig) - if err != nil { - log.Fatalf("Error connecting to DB: %v\n", err) - } - blockchain.RegisterObserver(core.BlockchainDBObserver{Db: db}) - blockchain.SubscribeToEvents() -}