Remove admin api dependency (#126)
This commit is contained in:
parent
54c4f0c2fe
commit
14e1fc4213
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user