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 authored and GitHub committed 2019-08-29 09:13:48 +02:00
commit 281c535b49
1 file changed
+9 -5
+9 -5
View File
@@ -3770,16 +3770,20 @@ func (r *rpcServer) DescribeGraph(ctx context.Context,
func marshalDbEdge(edgeInfo *channeldb.ChannelEdgeInfo, func marshalDbEdge(edgeInfo *channeldb.ChannelEdgeInfo,
c1, c2 *channeldb.ChannelEdgePolicy) *lnrpc.ChannelEdge { c1, c2 *channeldb.ChannelEdgePolicy) *lnrpc.ChannelEdge {
var ( // Order the edges by increasing pubkey.
lastUpdate int64 if bytes.Compare(edgeInfo.NodeKey2Bytes[:],
) edgeInfo.NodeKey1Bytes[:]) < 0 {
if c2 != nil { c2, c1 = c1, c2
lastUpdate = c2.LastUpdate.Unix()
} }
var lastUpdate int64
if c1 != nil { if c1 != nil {
lastUpdate = c1.LastUpdate.Unix() lastUpdate = c1.LastUpdate.Unix()
} }
if c2 != nil && c2.LastUpdate.Unix() > lastUpdate {
lastUpdate = c2.LastUpdate.Unix()
}
edge := &lnrpc.ChannelEdge{ edge := &lnrpc.ChannelEdge{
ChannelId: edgeInfo.ChannelID, ChannelId: edgeInfo.ChannelID,