4 Listening bool `json:"listening"`
5 Syncing bool `json:"syncing"`
6 Mining bool `json:"mining"`
7 PeerCount int `json:"peer_count"`
8 CurrentBlock uint64 `json:"current_block"`
9 HighestBlock uint64 `json:"highest_block"`
12 func (a *API) GetNodeInfo() *NetInfo {
14 Listening: a.sync.Switch().IsListening(),
15 Syncing: a.sync.BlockKeeper().IsCaughtUp(),
16 Mining: a.cpuMiner.IsMining(),
17 PeerCount: len(a.sync.Switch().Peers().List()),
18 CurrentBlock: a.chain.BestBlockHeight(),
20 _, info.HighestBlock = a.sync.Peers().BestPeer()
21 if info.CurrentBlock > info.HighestBlock {
22 info.HighestBlock = info.CurrentBlock
27 // return network infomation
28 func (a *API) getNetInfo() Response {
29 return NewSuccessResponse(a.GetNodeInfo())
32 // return is in mining or not
33 func (a *API) isMining() Response {
34 IsMining := map[string]bool{"isMining": a.IsMining()}
35 return NewSuccessResponse(IsMining)
38 func (a *API) IsMining() bool {
39 return a.cpuMiner.IsMining()