OSDN Git Service

update
authorChengcheng Zhang <943420582@qq.com>
Fri, 12 Jul 2019 09:17:25 +0000 (17:17 +0800)
committerChengcheng Zhang <943420582@qq.com>
Fri, 12 Jul 2019 09:17:25 +0000 (17:17 +0800)
api/api.go
api/nodeinfo.go

index a030f39..e4230cb 100644 (file)
@@ -13,6 +13,7 @@ import (
 
        "github.com/vapor/accesstoken"
        cfg "github.com/vapor/config"
+       "github.com/vapor/crypto/ed25519/chainkd"
        "github.com/vapor/dashboard/dashboard"
        "github.com/vapor/dashboard/equity"
        "github.com/vapor/errors"
@@ -106,6 +107,7 @@ func (wh *waitHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
 // API is the scheduling center for server
 type API struct {
        sync            NetSync
+       peerXPub        chainkd.XPub
        wallet          *wallet.Wallet
        accessTokens    *accesstoken.CredentialStore
        chain           *protocol.Chain
@@ -144,6 +146,7 @@ func (a *API) initServer(config *cfg.Config) {
                // https://github.com/golang/go/issues/17071
                TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){},
        }
+       a.peerXPub = config.PrivateKey().XPub()
 
        coreHandler.Set(a)
 }
index b00c8fd..e7d15c6 100644 (file)
@@ -21,6 +21,7 @@ type NetInfo struct {
        Listening    bool         `json:"listening"`
        Syncing      bool         `json:"syncing"`
        Mining       bool         `json:"mining"`
+       PeerXPub     string       `json:"peer_xpub"`
        PeerCount    int          `json:"peer_count"`
        CurrentBlock uint64       `json:"current_block"`
        HighestBlock uint64       `json:"highest_block"`
@@ -34,6 +35,7 @@ func (a *API) GetNodeInfo() *NetInfo {
                Listening:    a.sync.IsListening(),
                Syncing:      !a.sync.IsCaughtUp(),
                Mining:       a.blockProposer.IsProposing(),
+               PeerXPub:     a.peerXPub.String(),
                PeerCount:    a.sync.PeerCount(),
                CurrentBlock: a.chain.BestBlockHeight(),
                NetWorkID:    a.sync.GetNetwork(),