add err logging to eth/node
This commit is contained in:
parent
37f4a2d603
commit
563832422c
@ -18,17 +18,15 @@ package node
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"log"
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IPropertiesReader interface {
|
type IPropertiesReader interface {
|
||||||
@ -101,7 +99,7 @@ func (reader PropertiesReader) NetworkID() float64 {
|
|||||||
var version string
|
var version string
|
||||||
err := reader.client.CallContext(context.Background(), &version, "net_version")
|
err := reader.client.CallContext(context.Background(), &version, "net_version")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
networkID, _ := strconv.ParseFloat(version, 64)
|
networkID, _ := strconv.ParseFloat(version, 64)
|
||||||
return networkID
|
return networkID
|
||||||
@ -111,13 +109,19 @@ func (reader PropertiesReader) GenesisBlock() string {
|
|||||||
var header *types.Header
|
var header *types.Header
|
||||||
blockZero := "0x0"
|
blockZero := "0x0"
|
||||||
includeTransactions := false
|
includeTransactions := false
|
||||||
reader.client.CallContext(context.Background(), &header, "eth_getBlockByNumber", blockZero, includeTransactions)
|
err := reader.client.CallContext(context.Background(), &header, "eth_getBlockByNumber", blockZero, includeTransactions)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
return header.Hash().Hex()
|
return header.Hash().Hex()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (reader PropertiesReader) NodeInfo() (string, string) {
|
func (reader PropertiesReader) NodeInfo() (string, string) {
|
||||||
var info p2p.NodeInfo
|
var info p2p.NodeInfo
|
||||||
reader.client.CallContext(context.Background(), &info, "admin_nodeInfo")
|
err := reader.client.CallContext(context.Background(), &info, "admin_nodeInfo")
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
return info.ID, info.Name
|
return info.ID, info.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,14 +141,20 @@ func (client GanacheClient) NodeInfo() (string, string) {
|
|||||||
|
|
||||||
func (client ParityClient) parityNodeInfo() string {
|
func (client ParityClient) parityNodeInfo() string {
|
||||||
var nodeInfo core.ParityNodeInfo
|
var nodeInfo core.ParityNodeInfo
|
||||||
client.client.CallContext(context.Background(), &nodeInfo, "parity_versionInfo")
|
err := client.client.CallContext(context.Background(), &nodeInfo, "parity_versionInfo")
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
return nodeInfo.String()
|
return nodeInfo.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client ParityClient) parityID() string {
|
func (client ParityClient) parityID() string {
|
||||||
var enodeID = regexp.MustCompile(`^enode://(.+)@.+$`)
|
var enodeID = regexp.MustCompile(`^enode://(.+)@.+$`)
|
||||||
var enodeURL string
|
var enodeURL string
|
||||||
client.client.CallContext(context.Background(), &enodeURL, "parity_enode")
|
err := client.client.CallContext(context.Background(), &enodeURL, "parity_enode")
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
enode := enodeID.FindStringSubmatch(enodeURL)
|
enode := enodeID.FindStringSubmatch(enodeURL)
|
||||||
if len(enode) < 2 {
|
if len(enode) < 2 {
|
||||||
return ""
|
return ""
|
||||||
|
Loading…
Reference in New Issue
Block a user