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