mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 05:41:21 +00:00
rpc cleanup; tendermint init
This commit is contained in:
@ -125,6 +125,7 @@ var DefaultGenesis = `{
|
||||
// NOTE: If you change this, maybe also change defaultConfig
|
||||
func initDefaults(rootDir string) {
|
||||
app.SetDefault("network", "tendermint_testnet0")
|
||||
app.SetDefault("version", "0.2.1")
|
||||
app.SetDefault("genesis_file", rootDir+"/genesis.json")
|
||||
app.SetDefault("moniker", "anonymous")
|
||||
app.SetDefault("node_laddr", "0.0.0.0:46656")
|
||||
|
@ -32,7 +32,7 @@ type Node struct {
|
||||
client *NodeClient
|
||||
|
||||
LastSeen time.Time
|
||||
GenesisHash []byte
|
||||
Network string
|
||||
BlockHeight uint
|
||||
BlockHistory map[uint]time.Time // when we saw each block
|
||||
NetInfo *rpctypes.ResponseNetInfo
|
||||
@ -50,7 +50,7 @@ func (n *Node) Address() string {
|
||||
// Set the basic status and network info for a node from RPC responses
|
||||
func (n *Node) SetInfo(status *rpctypes.ResponseStatus, netinfo *rpctypes.ResponseNetInfo) {
|
||||
n.LastSeen = time.Now()
|
||||
n.GenesisHash = status.GenesisHash
|
||||
n.Network = status.Network
|
||||
n.BlockHeight = status.LatestBlockHeight
|
||||
n.NetInfo = netinfo
|
||||
// n.Validator
|
||||
|
@ -187,6 +187,7 @@ func (n *Node) StartRPC() {
|
||||
core.SetConsensusReactor(n.consensusReactor)
|
||||
core.SetMempoolReactor(n.mempoolReactor)
|
||||
core.SetSwitch(n.sw)
|
||||
core.SetPrivValidator(n.privValidator)
|
||||
|
||||
listenAddr := config.App().GetString("rpc_laddr")
|
||||
mux := http.NewServeMux()
|
||||
@ -215,7 +216,7 @@ func makeNodeInfo(sw *p2p.Switch) *types.NodeInfo {
|
||||
nodeInfo := &types.NodeInfo{
|
||||
Network: config.App().GetString("network"),
|
||||
Moniker: config.App().GetString("moniker"),
|
||||
Version: "0.2.0", // Everything is in Big Endian.
|
||||
Version: config.App().GetString("version"),
|
||||
}
|
||||
if !sw.IsListening() {
|
||||
return nodeInfo
|
||||
|
@ -26,15 +26,21 @@ func Status() (*ctypes.ResponseStatus, error) {
|
||||
latestBlockTime = latestBlockMeta.Header.Time.UnixNano()
|
||||
}
|
||||
|
||||
return &ctypes.ResponseStatus{genesisHash, config.App().GetString("network"), latestBlockHash, latestHeight, latestBlockTime}, nil
|
||||
return &ctypes.ResponseStatus{
|
||||
Moniker: config.App().GetString("moniker"),
|
||||
Network: config.App().GetString("network"),
|
||||
Version: config.App().GetString("version"),
|
||||
GenesisHash: genesisHash,
|
||||
PubKey: privValidator.PubKey,
|
||||
LatestBlockHash: latestBlockHash,
|
||||
LatestBlockHeight: latestHeight,
|
||||
LatestBlockTime: latestBlockTime}, nil
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
func NetInfo() (*ctypes.ResponseNetInfo, error) {
|
||||
listening := p2pSwitch.IsListening()
|
||||
moniker := config.App().GetString("moniker")
|
||||
network := config.App().GetString("network")
|
||||
listeners := []string{}
|
||||
for _, listener := range p2pSwitch.Listeners() {
|
||||
listeners = append(listeners, listener.String())
|
||||
@ -47,8 +53,6 @@ func NetInfo() (*ctypes.ResponseNetInfo, error) {
|
||||
})
|
||||
}
|
||||
return &ctypes.ResponseNetInfo{
|
||||
Moniker: moniker,
|
||||
Network: network,
|
||||
Listening: listening,
|
||||
Listeners: listeners,
|
||||
Peers: peers,
|
||||
|
@ -13,6 +13,7 @@ var consensusState *consensus.ConsensusState
|
||||
var consensusReactor *consensus.ConsensusReactor
|
||||
var mempoolReactor *mempl.MempoolReactor
|
||||
var p2pSwitch *p2p.Switch
|
||||
var privValidator *state.PrivValidator
|
||||
|
||||
func SetBlockStore(bs *bc.BlockStore) {
|
||||
blockStore = bs
|
||||
@ -34,7 +35,6 @@ func SetSwitch(sw *p2p.Switch) {
|
||||
p2pSwitch = sw
|
||||
}
|
||||
|
||||
// JAE Why is this here?
|
||||
func SetPrivValidator(priv *state.PrivValidator) {
|
||||
consensusReactor.SetPrivValidator(priv)
|
||||
func SetPrivValidator(pv *state.PrivValidator) {
|
||||
privValidator = pv
|
||||
}
|
||||
|
@ -65,16 +65,17 @@ type Receipt struct {
|
||||
}
|
||||
|
||||
type ResponseStatus struct {
|
||||
GenesisHash []byte `json:"genesis_hash"`
|
||||
Moniker string `json:"moniker"`
|
||||
Network string `json:"network"`
|
||||
Version string `json:"version"`
|
||||
GenesisHash []byte `json:"genesis_hash"`
|
||||
PubKey account.PubKey `json:"pub_key"`
|
||||
LatestBlockHash []byte `json:"latest_block_hash"`
|
||||
LatestBlockHeight uint `json:"latest_block_height"`
|
||||
LatestBlockTime int64 `json:"latest_block_time"` // nano
|
||||
}
|
||||
|
||||
type ResponseNetInfo struct {
|
||||
Moniker string `json:"moniker"`
|
||||
Network string `json:"network"`
|
||||
Listening bool `json:"listening"`
|
||||
Listeners []string `json:"listeners"`
|
||||
Peers []Peer `json:"peers"`
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"testing"
|
||||
)
|
||||
@ -91,9 +90,6 @@ func testGetStorage(t *testing.T, typ string) {
|
||||
unsubscribe(t, con, eid)
|
||||
con.Close()
|
||||
}()
|
||||
priv := state.LoadPrivValidator(".tendermint/priv_validator.json")
|
||||
_ = priv
|
||||
//core.SetPrivValidator(priv)
|
||||
|
||||
amt := uint64(1100)
|
||||
code := []byte{0x60, 0x5, 0x60, 0x1, 0x55}
|
||||
|
Reference in New Issue
Block a user