mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-01 02:51:37 +02:00
lnrpc+autopilot: add graph diameter calculation
* adds a brute force computation of the diameter * adds a more efficient calculation of the diameter
This commit is contained in:
12
rpcserver.go
12
rpcserver.go
@ -5904,10 +5904,20 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context,
|
||||
minChannelSize = 0
|
||||
}
|
||||
|
||||
// TODO(roasbeef): graph diameter
|
||||
// Graph diameter.
|
||||
channelGraph := autopilot.ChannelGraphFromDatabase(graph)
|
||||
simpleGraph, err := autopilot.NewSimpleGraph(channelGraph)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
start := time.Now()
|
||||
diameter := simpleGraph.DiameterRadialCutoff()
|
||||
rpcsLog.Infof("elapsed time for diameter (%d) calculation: %v", diameter,
|
||||
time.Since(start))
|
||||
|
||||
// TODO(roasbeef): also add oldest channel?
|
||||
netInfo := &lnrpc.NetworkInfo{
|
||||
GraphDiameter: diameter,
|
||||
MaxOutDegree: maxChanOut,
|
||||
AvgOutDegree: float64(2*numChannels) / float64(numNodes),
|
||||
NumNodes: numNodes,
|
||||
|
Reference in New Issue
Block a user