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() -}