Skip to content

Commit

Permalink
Merge pull request #846 from lochjin/dev2.0
Browse files Browse the repository at this point in the history
feat:optimize networkinfo for snapsync
  • Loading branch information
dindinw authored Dec 12, 2024
2 parents 353a76e + fab609f commit c0f428b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/json/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ type NetworkStat struct {
TotalConnected int `json:"totalconnected"`
TotalRelays int `json:"totalrelays"`
Infos []*NetworkInfo `json:"infos"`
Services string `json:"services"`
Snap bool `json:"snap"`
SnapSync *SnapSyncInfo `json:"snapsync,omitempty"`
}

Expand Down
2 changes: 2 additions & 0 deletions p2p/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ func (api *PublicP2PAPI) GetNetworkInfo() (interface{}, error) {
MaxConnected: ps.Config().MaxPeers,
MaxInbound: ps.Config().MaxInbound,
Infos: []*json.NetworkInfo{},
Services: ps.Config().Services.String(),
Snap: ps.IsSnap(),
}
ss := ps.PeerSync().GetSnapSyncInfo()
if ss != nil {
Expand Down
4 changes: 4 additions & 0 deletions p2p/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,10 @@ func (s *Service) Consensus() model.Consensus {
return s.consensus
}

func (s *Service) IsSnap() bool {
return pv.HasServices(s.cfg.Services, pv.Snap)
}

func (s *Service) IsSnapSync() bool {
return s.PeerSync().IsSnapSync()
}
Expand Down

0 comments on commit c0f428b

Please sign in to comment.