OSDN Git Service
(root)
/
bytom
/
vapor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
modify tip (#271)
[bytom/vapor.git]
/
api
/
nodeinfo.go
diff --git
a/api/nodeinfo.go
b/api/nodeinfo.go
index
c0b55c1
..
b00c8fd
100644
(file)
--- a/
api/nodeinfo.go
+++ b/
api/nodeinfo.go
@@
-5,7
+5,7
@@
import (
"net"
"github.com/vapor/errors"
"net"
"github.com/vapor/errors"
- "github.com/vapor/netsync"
+ "github.com/vapor/netsync
/peers
"
"github.com/vapor/p2p"
"github.com/vapor/version"
)
"github.com/vapor/p2p"
"github.com/vapor/version"
)
@@
-31,12
+31,12
@@
type NetInfo struct {
// GetNodeInfo return net information
func (a *API) GetNodeInfo() *NetInfo {
info := &NetInfo{
// GetNodeInfo return net information
func (a *API) GetNodeInfo() *NetInfo {
info := &NetInfo{
- Listening: a.sync.
Switch().
IsListening(),
+ Listening: a.sync.IsListening(),
Syncing: !a.sync.IsCaughtUp(),
Syncing: !a.sync.IsCaughtUp(),
- Mining: a.
cpuMiner.IsMin
ing(),
- PeerCount:
len(a.sync.Switch().Peers().List()
),
+ Mining: a.
blockProposer.IsPropos
ing(),
+ PeerCount:
a.sync.PeerCount(
),
CurrentBlock: a.chain.BestBlockHeight(),
CurrentBlock: a.chain.BestBlockHeight(),
- NetWorkID: a.sync.
NodeInfo().Network
,
+ NetWorkID: a.sync.
GetNetwork()
,
Version: &VersionInfo{
Version: version.Version,
Update: version.Status.VersionStatus(),
Version: &VersionInfo{
Version: version.Version,
Update: version.Status.VersionStatus(),
@@
-53,7
+53,7
@@
func (a *API) GetNodeInfo() *NetInfo {
}
// return the currently connected peers with net address
}
// return the currently connected peers with net address
-func (a *API) getPeerInfoByAddr(addr string) *
netsync
.PeerInfo {
+func (a *API) getPeerInfoByAddr(addr string) *
peers
.PeerInfo {
peerInfos := a.sync.GetPeerInfos()
for _, peerInfo := range peerInfos {
if peerInfo.RemoteAddr == addr {
peerInfos := a.sync.GetPeerInfos()
for _, peerInfo := range peerInfos {
if peerInfo.RemoteAddr == addr {
@@
-69,16
+69,15
@@
func (a *API) disconnectPeerById(peerID string) error {
}
// connect peer b y net address
}
// connect peer b y net address
-func (a *API) connectPeerByIpAndPort(ip string, port uint16) (*
netsync
.PeerInfo, error) {
+func (a *API) connectPeerByIpAndPort(ip string, port uint16) (*
peers
.PeerInfo, error) {
netIp := net.ParseIP(ip)
if netIp == nil {
return nil, errors.New("invalid ip address")
}
addr := p2p.NewNetAddressIPPort(netIp, port)
netIp := net.ParseIP(ip)
if netIp == nil {
return nil, errors.New("invalid ip address")
}
addr := p2p.NewNetAddressIPPort(netIp, port)
- sw := a.sync.Switch()
- if err :=
sw
.DialPeerWithAddress(addr); err != nil {
+ if err :=
a.sync
.DialPeerWithAddress(addr); err != nil {
return nil, errors.Wrap(err, "can not connect to the address")
}
peer := a.getPeerInfoByAddr(addr.String())
return nil, errors.Wrap(err, "can not connect to the address")
}
peer := a.getPeerInfoByAddr(addr.String())
@@
-99,9
+98,9
@@
func (a *API) isMining() Response {
return NewSuccessResponse(IsMining)
}
return NewSuccessResponse(IsMining)
}
-// Is
Min
ing return mining status
+// Is
Propos
ing return mining status
func (a *API) IsMining() bool {
func (a *API) IsMining() bool {
- return a.
cpuMiner.IsMin
ing()
+ return a.
blockProposer.IsPropos
ing()
}
// return the peers of current node
}
// return the peers of current node