diff --git a/pkg/geth/block_to_core_block.go b/pkg/geth/block_to_core_block.go index c82000dd..34df1660 100644 --- a/pkg/geth/block_to_core_block.go +++ b/pkg/geth/block_to_core_block.go @@ -58,6 +58,10 @@ func convertTransactionsToCore(gethBlock *types.Block, client GethClient) []core func appendReceiptToTransaction(client GethClient, transaction core.Transaction) (core.Transaction, error) { gethReceipt, err := client.TransactionReceipt(context.Background(), common.HexToHash(transaction.Hash)) + if err != nil { + log.Println(err) + return transaction, err + } receipt := ReceiptToCoreReceipt(gethReceipt) transaction.Receipt = receipt return transaction, err diff --git a/pkg/geth/node/node.go b/pkg/geth/node/node.go index 38fcfe6d..524316dd 100644 --- a/pkg/geth/node/node.go +++ b/pkg/geth/node/node.go @@ -3,30 +3,26 @@ package node import ( "context" + "strconv" + "github.com/8thlight/vulcanizedb/pkg/core" - "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" ) func Retrieve(client *rpc.Client) core.Node { - var info p2p.NodeInfo node := core.Node{} - client.CallContext(context.Background(), &info, "admin_nodeInfo") - for protocolName, protocol := range info.Protocols { - if protocolName == "eth" { - protocolMap, _ := protocol.(map[string]interface{}) - node.GenesisBlock = getAttribute(protocolMap, "genesis").(string) - node.NetworkId = getAttribute(protocolMap, "network").(float64) - } - } + + var version string + client.CallContext(context.Background(), &version, "net_version") + node.NetworkId, _ = strconv.ParseFloat(version, 64) + + var protocolVersion string + client.CallContext(context.Background(), &protocolVersion, "eth_protocolVersion") + + var header *types.Header + client.CallContext(context.Background(), &header, "eth_getBlockByNumber", "0x0", false) + node.GenesisBlock = header.Hash().Hex() + return node } - -func getAttribute(protocolMap map[string]interface{}, protocol string) interface{} { - for key, val := range protocolMap { - if key == protocol { - return val - } - } - return nil -}