You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
991 B

package rpc
import (
"github.com/tendermint/tendermint/config"
"net/http"
)
func StatusHandler(w http.ResponseWriter, r *http.Request) {
genesisHash := blockStore.LoadBlockMeta(0).Hash
latestHeight := blockStore.Height()
latestBlockMeta := blockStore.LoadBlockMeta(latestHeight)
latestBlockHash := latestBlockMeta.Hash
latestBlockTime := latestBlockMeta.Header.Time.UnixNano()
WriteAPIResponse(w, API_OK, struct {
GenesisHash []byte
LatestBlockHash []byte
LatestBlockHeight uint
LatestBlockTime int64 // nano
Network string
}{genesisHash, latestBlockHash, latestHeight, latestBlockTime, config.App().GetString("Network")})
}
func NetInfoHandler(w http.ResponseWriter, r *http.Request) {
o, i, _ := p2pSwitch.NumPeers()
numPeers := o + i
listening := p2pSwitch.IsListening()
network := config.App().GetString("Network")
WriteAPIResponse(w, API_OK, struct {
NumPeers int
Listening bool
Network string
}{numPeers, listening, network})
}