Allow for multiple Geth nodes (#128)
This commit is contained in:
+14
-1
@@ -3,6 +3,8 @@ package geth
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"strings"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/geth/node"
|
||||
"github.com/ethereum/go-ethereum"
|
||||
@@ -25,11 +27,22 @@ func NewBlockchain(ipcPath string) *Blockchain {
|
||||
blockchain := Blockchain{}
|
||||
rpcClient, _ := rpc.Dial(ipcPath)
|
||||
client := ethclient.NewClient(rpcClient)
|
||||
blockchain.node = node.Retrieve(rpcClient)
|
||||
blockchain.node = node.Info(rpcClient)
|
||||
if infura := isInfuraNode(ipcPath); infura {
|
||||
blockchain.node.Id = "infura"
|
||||
blockchain.node.ClientName = "infura"
|
||||
}
|
||||
blockchain.client = client
|
||||
return &blockchain
|
||||
}
|
||||
|
||||
func isInfuraNode(ipcPath string) bool {
|
||||
if strings.Contains(ipcPath, "infura") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (blockchain *Blockchain) GetLogs(contract core.Contract, startingBlockNumber *big.Int, endingBlockNumber *big.Int) ([]core.Log, error) {
|
||||
if endingBlockNumber == nil {
|
||||
endingBlockNumber = startingBlockNumber
|
||||
|
||||
Reference in New Issue
Block a user