Skip to content
Snippets Groups Projects
Unverified Commit 7fbac989 authored by Benjamin Bollen's avatar Benjamin Bollen
Browse files

client: complete rpc chainId for chainname, chainid, and genesisHash

parent c7c938cd
No related branches found
No related tags found
No related merge requests found
......@@ -100,7 +100,7 @@ func (erisNodeClient *ErisNodeClient) Status() (GenesisHash []byte, ValidatorPub
func (erisNodeClient *ErisNodeClient) ChainId() (ChainName, ChainId string, GenesisHash []byte, err error) {
client := rpcclient.NewClientJSONRPC(erisNodeClient.broadcastRPC)
chainIdResult, err := tendermint_client.ChainId()
chainIdResult, err := tendermint_client.ChainId(client)
if err != nil {
err = fmt.Errorf("Error connecting to node (%s) to get chain id: %s",
erisNodeClient.broadcastRPC, err.Error())
......
......@@ -22,11 +22,11 @@ import (
"strconv"
// "strings"
// "time"
log "github.com/eris-ltd/eris-logger"
ptypes "github.com/eris-ltd/eris-db/permission/types"
// log "github.com/eris-ltd/eris-logger"
"github.com/eris-ltd/eris-db/account"
"github.com/eris-ltd/eris-db/client"
"github.com/eris-ltd/eris-db/keys"
"github.com/eris-ltd/eris-db/txs"
......@@ -281,9 +281,7 @@ func SignAndBroadcast(chainID string, nodeClient client.NodeClient, keyClient ke
return nil, err
}
log.WithFields(log.Fields{
"transaction sign bytes": fmt.Sprintf("%X", signBytes),
"account address": fmt.Sprintf("%X", inputAddr),
"signature": fmt.Sprintf("%X", sig64),
"transaction": string(account.SignBytes(chainID, tx)),
}).Debug("Signed transaction")
}
......
......@@ -20,6 +20,8 @@ import (
"fmt"
"testing"
// "github.com/stretchr/testify/assert"
mockclient "github.com/eris-ltd/eris-db/client/mock"
mockkeys "github.com/eris-ltd/eris-db/keys/mock"
)
......@@ -60,6 +62,7 @@ func testTransactionFactorySend(t *testing.T,
t.Logf("Error in SendTx: %s", err)
t.Fail()
}
// assert.NotEqual(t, txSend)
// TODO: test content of Transaction
}
......
......@@ -27,17 +27,27 @@ import (
func Status(do *definitions.ClientDo) {
erisNodeClient := client.NewErisNodeClient(do.NodeAddrFlag)
chainId, validatorPublicKey, latestBlockHash, latestBlockHeight, latestBlockTime, err := erisNodeClient.Status()
genesisHash, validatorPublicKey, latestBlockHash, latestBlockHeight, latestBlockTime, err := erisNodeClient.Status()
if err != nil {
log.Errorf("Error requesting status from chain at (%s): %s", do.NodeAddrFlag, err)
return
}
}
chainName, chainId, genesisHashfromChainId, err := erisNodeClient.ChainId()
if err != nil {
log.Errorf("Error requesting chainId from chain at (%s): %s", do.NodeAddrFlag, err)
return
}
log.WithFields(log.Fields{
"chain": do.NodeAddrFlag,
"chainid": fmt.Sprintf("%X", chainId),
"genesisHash": fmt.Sprintf("%X", genesisHash),
"chainName": chainName,
"chainId": chainId,
"genesisHash from chainId":fmt.Sprintf("%X", genesisHashfromChainId),
"validator public key": fmt.Sprintf("%X", validatorPublicKey),
"latest block hash": fmt.Sprintf("%X", latestBlockHash),
"latest block height": latestBlockHeight,
"latest block time": latestBlockTime,
}).Info("status")
}
\ No newline at end of file
}
......@@ -41,6 +41,7 @@ type TendermintPipe interface {
Status() (*rpc_tm_types.ResultStatus, error)
NetInfo() (*rpc_tm_types.ResultNetInfo, error)
Genesis() (*rpc_tm_types.ResultGenesis, error)
ChainId() (*rpc_tm_types.ResultChainId, error)
// Accounts
GetAccount(address []byte) (*rpc_tm_types.ResultGetAccount, error)
......
......@@ -311,13 +311,13 @@ func (pipe *erisMintPipe) ChainId() (*rpc_tm_types.ResultChainId, error) {
if pipe.blockchain == nil {
return nil, fmt.Errorf("Blockchain not initialised in Erismint pipe.")
}
chainId := pipe.blockchain().ChainId()
chainId := pipe.blockchain.ChainId()
return &rpc_tm_types.ResultChainId{
ChainName: chainId, // MARMOT: copy ChainId for ChainName as a placehodlder
ChainId: chainId,
GenesisHash: pipe.GenesisHash(),
}
}, nil
}
func (pipe *erisMintPipe) NetInfo() (*rpc_tm_types.ResultNetInfo, error) {
......
......@@ -20,7 +20,7 @@ func Status(client rpcclient.Client) (*rpc_types.ResultStatus, error) {
return res.(*rpc_types.ResultStatus), nil
}
func ChainId(client rpcclient.Client) (*rpc_types.ResultChainId) {
func ChainId(client rpcclient.Client) (*rpc_types.ResultChainId, error) {
res, err := performCall(client, "chain_id")
if err != nil {
return nil, err
......
......@@ -62,7 +62,7 @@ type ResultStatus struct {
type ResultChainId struct {
ChainName string `json:"chain_name"`
ChainID string `json:"chain_id"`
ChainId string `json:"chain_id"`
GenesisHash []byte `json:"genesis_hash"`
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment