OSDN Git Service

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

index e4230cb..a030f39 100644 (file)
@@ -13,7 +13,6 @@ 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"
@@ -107,7 +106,6 @@ 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
@@ -146,7 +144,6 @@ 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 e7d15c6..17c9a35 100644 (file)
@@ -4,6 +4,7 @@ import (
        "context"
        "net"
 
+       cfg "github.com/vapor/config"
        "github.com/vapor/errors"
        "github.com/vapor/netsync/peers"
        "github.com/vapor/p2p"
@@ -21,7 +22,7 @@ type NetInfo struct {
        Listening    bool         `json:"listening"`
        Syncing      bool         `json:"syncing"`
        Mining       bool         `json:"mining"`
-       PeerXPub     string       `json:"peer_xpub"`
+       NodeXPub     string       `json:"peer_xpub"`
        PeerCount    int          `json:"peer_count"`
        CurrentBlock uint64       `json:"current_block"`
        HighestBlock uint64       `json:"highest_block"`
@@ -31,11 +32,12 @@ type NetInfo struct {
 
 // GetNodeInfo return net information
 func (a *API) GetNodeInfo() *NetInfo {
+       nodeXPub := cfg.CommonConfig.PrivateKey().XPub()
        info := &NetInfo{
                Listening:    a.sync.IsListening(),
                Syncing:      !a.sync.IsCaughtUp(),
                Mining:       a.blockProposer.IsProposing(),
-               PeerXPub:     a.peerXPub.String(),
+               NodeXPub:     nodeXPub.String(),
                PeerCount:    a.sync.PeerCount(),
                CurrentBlock: a.chain.BestBlockHeight(),
                NetWorkID:    a.sync.GetNetwork(),