Merge pull request #3427 from cfromknecht/node-info-update-order

rpcserver: order updates in getnodeinfo by increasing pubkey
This commit is contained in:
Johan T. Halseth 2019-08-29 09:13:48 +02:00 committed by GitHub
commit 281c535b49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3770,16 +3770,20 @@ func (r *rpcServer) DescribeGraph(ctx context.Context,
func marshalDbEdge(edgeInfo *channeldb.ChannelEdgeInfo,
c1, c2 *channeldb.ChannelEdgePolicy) *lnrpc.ChannelEdge {
var (
lastUpdate int64
)
// Order the edges by increasing pubkey.
if bytes.Compare(edgeInfo.NodeKey2Bytes[:],
edgeInfo.NodeKey1Bytes[:]) < 0 {
if c2 != nil {
lastUpdate = c2.LastUpdate.Unix()
c2, c1 = c1, c2
}
var lastUpdate int64
if c1 != nil {
lastUpdate = c1.LastUpdate.Unix()
}
if c2 != nil && c2.LastUpdate.Unix() > lastUpdate {
lastUpdate = c2.LastUpdate.Unix()
}
edge := &lnrpc.ChannelEdge{
ChannelId: edgeInfo.ChannelID,