Skip to content

Commit

Permalink
[stream] pretty format for sync metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyWYX committed Feb 26, 2021
1 parent c083832 commit 6dd0f99
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hmy/hmy.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type NodeAPI interface {
IsCurrentlyLeader() bool
IsOutOfSync(shardID uint32) bool
SyncStatus(shardID uint32) (bool, uint64)
SyncPeers() map[uint32]int
SyncPeers() map[string]int
ReportStakingErrorSink() types.TransactionErrorReports
ReportPlainErrorSink() types.TransactionErrorReports
PendingCXReceipts() []*types.CXReceiptsProof
Expand Down
10 changes: 8 additions & 2 deletions node/node_syncing.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,18 @@ func (node *Node) IsOutOfSync(shardID uint32) bool {
}

// SyncPeers return connected sync peers for each shard
func (node *Node) SyncPeers() map[uint32]int {
func (node *Node) SyncPeers() map[string]int {
ds := node.getDownloaders()
if ds == nil {
return nil
}
return ds.NumPeers()
nums := ds.NumPeers()
res := make(map[string]int)
for sid, num := range nums {
s := fmt.Sprintf("shard-%v", sid)
res[s] = num
}
return res
}

func (node *Node) getDownloaders() *downloader.Downloaders {
Expand Down
2 changes: 1 addition & 1 deletion rpc/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type NodeMetadata struct {
PeerID peer.ID `json:"peerid"`
Consensus ConsensusInternal `json:"consensus"`
C C `json:"p2p-connectivity"`
SyncPeers map[uint32]int `json:"sync-peers",omitempty`
SyncPeers map[string]int `json:"sync-peers",omitempty`
}

// P captures the connected peers per topic
Expand Down

0 comments on commit 6dd0f99

Please sign in to comment.