Official Go implementation of the Bytom protocol
Revision | c0efc8336ab3511b79658e2675e082da86fd79a9 (tree) |
---|---|
Zeit | 2021-06-30 14:55:17 |
Autor | shenao78 <shenao.78@163....> |
Commiter | shenao78 |
add_node_xpub_for_net_info
@@ -4,6 +4,7 @@ import ( | ||
4 | 4 | "context" |
5 | 5 | "net" |
6 | 6 | |
7 | + "github.com/bytom/bytom/config" | |
7 | 8 | "github.com/bytom/bytom/errors" |
8 | 9 | "github.com/bytom/bytom/netsync/peers" |
9 | 10 | "github.com/bytom/bytom/p2p" |
@@ -21,6 +22,7 @@ type NetInfo struct { | ||
21 | 22 | Listening bool `json:"listening"` |
22 | 23 | Syncing bool `json:"syncing"` |
23 | 24 | Mining bool `json:"mining"` |
25 | + NodeXPub string `json:"node_xpub"` | |
24 | 26 | PeerCount int `json:"peer_count"` |
25 | 27 | CurrentBlock uint64 `json:"current_block"` |
26 | 28 | HighestBlock uint64 `json:"highest_block"` |
@@ -31,6 +33,7 @@ type NetInfo struct { | ||
31 | 33 | |
32 | 34 | // GetNodeInfo return net information |
33 | 35 | func (a *API) GetNodeInfo() (*NetInfo, error) { |
36 | + nodeXPub := config.CommonConfig.PrivateKey().XPub() | |
34 | 37 | finalizedBlockHeader, err := a.chain.LastFinalizedHeader() |
35 | 38 | if err != nil { |
36 | 39 | return nil, err |
@@ -40,6 +43,7 @@ func (a *API) GetNodeInfo() (*NetInfo, error) { | ||
40 | 43 | Listening: a.sync.IsListening(), |
41 | 44 | Syncing: !a.sync.IsCaughtUp(), |
42 | 45 | Mining: a.blockProposer.IsProposing(), |
46 | + NodeXPub: nodeXPub.String(), | |
43 | 47 | PeerCount: a.sync.PeerCount(), |
44 | 48 | CurrentBlock: a.chain.BestBlockHeight(), |
45 | 49 | FinalizedBlock: finalizedBlockHeader.Height, |