htlcswitch: modify interfaceIndex to no longer key 2nd lvl by ChannelLink
In this commit, we modify the interfaceIndex to no longer key the second level of the index by the ChannelLink. Instead, we'll use the chan ID as it's a stable identifier, unlike a reference to an interface.
This commit is contained in:
parent
1a15924d65
commit
03810603ee
@ -202,8 +202,8 @@ type Switch struct {
|
||||
forwardingIndex map[lnwire.ShortChannelID]ChannelLink
|
||||
|
||||
// interfaceIndex maps the compressed public key of a peer to all the
|
||||
// channels that the switch maintains iwht that peer.
|
||||
interfaceIndex map[[33]byte]map[ChannelLink]struct{}
|
||||
// channels that the switch maintains with that peer.
|
||||
interfaceIndex map[[33]byte]map[lnwire.ChannelID]ChannelLink
|
||||
|
||||
// htlcPlex is the channel which all connected links use to coordinate
|
||||
// the setup/teardown of Sphinx (onion routing) payment circuits.
|
||||
@ -253,7 +253,7 @@ func New(cfg Config) (*Switch, error) {
|
||||
linkIndex: make(map[lnwire.ChannelID]ChannelLink),
|
||||
mailOrchestrator: newMailOrchestrator(),
|
||||
forwardingIndex: make(map[lnwire.ShortChannelID]ChannelLink),
|
||||
interfaceIndex: make(map[[33]byte]map[ChannelLink]struct{}),
|
||||
interfaceIndex: make(map[[33]byte]map[lnwire.ChannelID]ChannelLink),
|
||||
pendingLinkIndex: make(map[lnwire.ChannelID]ChannelLink),
|
||||
pendingPayments: make(map[uint64]*pendingPayment),
|
||||
htlcPlex: make(chan *plexPacket),
|
||||
@ -1774,9 +1774,9 @@ func (s *Switch) addLiveLink(link ChannelLink) {
|
||||
// quickly look up all the channels for a particular node.
|
||||
peerPub := link.Peer().PubKey()
|
||||
if _, ok := s.interfaceIndex[peerPub]; !ok {
|
||||
s.interfaceIndex[peerPub] = make(map[ChannelLink]struct{})
|
||||
s.interfaceIndex[peerPub] = make(map[lnwire.ChannelID]ChannelLink)
|
||||
}
|
||||
s.interfaceIndex[peerPub][link] = struct{}{}
|
||||
s.interfaceIndex[peerPub][link.ChanID()] = link
|
||||
}
|
||||
|
||||
// GetLink is used to initiate the handling of the get link command. The
|
||||
@ -1918,7 +1918,7 @@ func (s *Switch) getLinks(destination [33]byte) ([]ChannelLink, error) {
|
||||
}
|
||||
|
||||
channelLinks := make([]ChannelLink, 0, len(links))
|
||||
for link := range links {
|
||||
for _, link := range links {
|
||||
channelLinks = append(channelLinks, link)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user