From cc05feee3f5dfb5eed71b763a61276cb4faec19c Mon Sep 17 00:00:00 2001 From: Eric Meyer Date: Mon, 23 Oct 2017 14:33:08 -0500 Subject: [PATCH] Pass in IPC path as command line argument --- core/geth_blockchain.go | 6 +++--- main.go | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/geth_blockchain.go b/core/geth_blockchain.go index b7df9d94..305e723b 100644 --- a/core/geth_blockchain.go +++ b/core/geth_blockchain.go @@ -13,10 +13,10 @@ type GethBlockchain struct { observers []BlockchainObserver } -func NewGethBlockchain() *GethBlockchain { - fmt.Println("Creating Geth Blockchain") +func NewGethBlockchain(ipcPath string) *GethBlockchain { + fmt.Printf("Creating Geth Blockchain to: %s\n", ipcPath) blockchain := GethBlockchain{} - client, _ := ethclient.Dial("/var/folders/b3/z7fhy7cs06q8d7y3_pwwt4x40000gn/T/ethereum_dev_mode/geth.ipc") + client, _ := ethclient.Dial(ipcPath) // TODO: handle error gracefully blockchain.client = client return &blockchain diff --git a/main.go b/main.go index ee24ef17..20a6d2cc 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,15 @@ package main import ( + "flag" "github.com/8thlight/vulcanizedb/core" ) func main() { - var blockchain core.Blockchain = core.NewGethBlockchain() + ipcPath := flag.String("ipcPath", "", "location geth.ipc") + flag.Parse() + + var blockchain core.Blockchain = core.NewGethBlockchain(*ipcPath) blockchain.RegisterObserver(core.BlockchainLoggingObserver{}) blockchain.SubscribeToEvents() }