ipld-eth-server/cmd/run/main.go

36 lines
981 B
Go

package main
import (
"fmt"
"log"
"flag"
"github.com/8thlight/vulcanizedb/pkg/blockchain_listener"
"github.com/8thlight/vulcanizedb/pkg/config"
"github.com/8thlight/vulcanizedb/pkg/core"
"github.com/8thlight/vulcanizedb/pkg/geth"
"github.com/8thlight/vulcanizedb/pkg/observers"
"github.com/8thlight/vulcanizedb/pkg/repositories"
)
func main() {
environment := flag.String("environment", "", "Environment name")
flag.Parse()
cfg, err := config.NewConfig(*environment)
if err != nil {
log.Fatalf("Error loading config\n%v", err)
}
fmt.Println("Client Path ", cfg.Client.IPCPath)
blockchain := geth.NewGethBlockchain(cfg.Client.IPCPath)
loggingObserver := observers.BlockchainLoggingObserver{}
repository := repositories.NewPostgres(cfg.Database)
dbObserver := observers.NewBlockchainDbObserver(repository)
listener := blockchain_listener.NewBlockchainListener(blockchain, []core.BlockchainObserver{
loggingObserver,
dbObserver,
})
listener.Start()
}