From 7b0d564692925bf2970257cfc489ee9d10236fa3 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 17 Mar 2020 16:24:10 -0700 Subject: [PATCH] discovery: move remotePubFromChanInfo to gossiper, remove utils --- discovery/gossiper.go | 16 ++++++++++++++++ discovery/utils.go | 22 ---------------------- 2 files changed, 16 insertions(+), 22 deletions(-) delete mode 100644 discovery/utils.go diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 742c260d..338558e7 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -1365,6 +1365,22 @@ func (d *AuthenticatedGossiper) processChanPolicyUpdate( return chanUpdates, nil } +// remotePubFromChanInfo returns the public key of the remote peer given a +// ChannelEdgeInfo that describe a channel we have with them. +func remotePubFromChanInfo(chanInfo *channeldb.ChannelEdgeInfo, + chanFlags lnwire.ChanUpdateChanFlags) [33]byte { + + var remotePubKey [33]byte + switch { + case chanFlags&lnwire.ChanUpdateDirection == 0: + remotePubKey = chanInfo.NodeKey2Bytes + case chanFlags&lnwire.ChanUpdateDirection == 1: + remotePubKey = chanInfo.NodeKey1Bytes + } + + return remotePubKey +} + // processRejectedEdge examines a rejected edge to see if we can extract any // new announcements from it. An edge will get rejected if we already added // the same edge without AuthProof to the graph. If the received announcement diff --git a/discovery/utils.go b/discovery/utils.go deleted file mode 100644 index 6a5e2dee..00000000 --- a/discovery/utils.go +++ /dev/null @@ -1,22 +0,0 @@ -package discovery - -import ( - "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/lnwire" -) - -// remotePubFromChanInfo returns the public key of the remote peer given a -// ChannelEdgeInfo that describe a channel we have with them. -func remotePubFromChanInfo(chanInfo *channeldb.ChannelEdgeInfo, - chanFlags lnwire.ChanUpdateChanFlags) [33]byte { - - var remotePubKey [33]byte - switch { - case chanFlags&lnwire.ChanUpdateDirection == 0: - remotePubKey = chanInfo.NodeKey2Bytes - case chanFlags&lnwire.ChanUpdateDirection == 1: - remotePubKey = chanInfo.NodeKey1Bytes - } - - return remotePubKey -}