OSDN Git Service

add getWorkJSON and submitWorkJSON
[bytom/bytom-spv.git] / api / nodeinfo.go
index dad2195..62f1d51 100644 (file)
@@ -1,5 +1,10 @@
 package api
 
+import (
+       "github.com/bytom/version"
+)
+
+// NetInfo indicate net information
 type NetInfo struct {
        Listening    bool   `json:"listening"`
        Syncing      bool   `json:"syncing"`
@@ -8,8 +13,10 @@ type NetInfo struct {
        CurrentBlock uint64 `json:"current_block"`
        HighestBlock uint64 `json:"highest_block"`
        NetWorkID    string `json:"network_id"`
+       Version      string `json:"version"`
 }
 
+// GetNodeInfo return net information
 func (a *API) GetNodeInfo() *NetInfo {
        info := &NetInfo{
                Listening:    a.sync.Switch().IsListening(),
@@ -18,6 +25,7 @@ func (a *API) GetNodeInfo() *NetInfo {
                PeerCount:    len(a.sync.Switch().Peers().List()),
                CurrentBlock: a.chain.BestBlockHeight(),
                NetWorkID:    a.sync.NodeInfo().Network,
+               Version:      version.Version,
        }
        _, info.HighestBlock = a.sync.Peers().BestPeer()
        if info.CurrentBlock > info.HighestBlock {
@@ -26,17 +34,18 @@ func (a *API) GetNodeInfo() *NetInfo {
        return info
 }
 
-// return network infomation
+// getNetInfo return network infomation
 func (a *API) getNetInfo() Response {
        return NewSuccessResponse(a.GetNodeInfo())
 }
 
-// return is in mining or not
+// isMining return is in mining or not
 func (a *API) isMining() Response {
-       IsMining := map[string]bool{"isMining": a.IsMining()}
+       IsMining := map[string]bool{"is_mining": a.IsMining()}
        return NewSuccessResponse(IsMining)
 }
 
+// IsMining return mining status
 func (a *API) IsMining() bool {
        return a.cpuMiner.IsMining()
 }