forked from cerc-io/ipld-eth-server
Refactor existing code to use Godo
This commit is contained in:
parent
e4fe3e0210
commit
121511f10d
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
|
Gododir/godobin-*
|
||||||
test_data_dir/
|
test_data_dir/
|
||||||
vendor/
|
vendor/
|
||||||
|
35
Gododir/main.go
Normal file
35
Gododir/main.go
Normal file
@ -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)
|
||||||
|
}
|
25
main.go
25
main.go
@ -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()
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user