MCPcopy Create free account
hub / github.com/encodeous/nylon / buildEndpoints

Function buildEndpoints

core/ipc_handler.go:207–232  ·  view source on GitHub ↗
(neigh *state.Neighbour)

Source from the content-addressed store, hash-verified

205}
206
207func buildEndpoints(neigh *state.Neighbour) []*protocol.EndpointInfo {
208 eps := make([]*protocol.EndpointInfo, 0, len(neigh.Eps))
209 for _, ep := range neigh.Eps {
210 nep := ep.AsNylonEndpoint()
211 var resolved *string
212 if ap, err := nep.DynEP.Get(); err == nil {
213 resolved = stringPtr(ap.String())
214 }
215 eps = append(eps, &protocol.EndpointInfo{
216 Address: nep.DynEP.Value,
217 Resolved: resolved,
218 Active: ep.IsActive(),
219 RemoteInit: ep.IsRemote(),
220 Metric: ep.Metric(),
221 FilteredRttNs: int64(nep.FilteredPing()),
222 StabilizedRttNs: int64(nep.StabilizedPing()),
223 })
224 }
225 slices.SortFunc(eps, func(a, b *protocol.EndpointInfo) int {
226 if cmpMetric := cmp.Compare(a.Metric, b.Metric); cmpMetric != 0 {
227 return cmpMetric
228 }
229 return cmp.Compare(a.Address, b.Address)
230 })
231 return eps
232}
233
234func buildNeighRoutes(neigh *state.Neighbour) []*protocol.NeighRoute {
235 routes := make([]*protocol.NeighRoute, 0, len(neigh.Routes))

Callers 1

buildNeighboursFunction · 0.85

Calls 9

stringPtrFunction · 0.85
FilteredPingMethod · 0.80
StabilizedPingMethod · 0.80
AsNylonEndpointMethod · 0.65
IsActiveMethod · 0.65
IsRemoteMethod · 0.65
MetricMethod · 0.65
GetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected