server: expose FindPeer for lnpeer.Peer to gossiper

This commit is contained in:
Conner Fromknecht 2018-06-07 20:09:40 -07:00
parent edf08458c1
commit a670537f4c
No known key found for this signature in database
GPG Key ID: 39DE78FBE6ACB0EF

@ -24,6 +24,7 @@ import (
"github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/discovery" "github.com/lightningnetwork/lnd/discovery"
"github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/lnpeer"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@ -441,6 +442,9 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl,
Broadcast: s.BroadcastMessage, Broadcast: s.BroadcastMessage,
ChanSeries: &chanSeries{s.chanDB.ChannelGraph()}, ChanSeries: &chanSeries{s.chanDB.ChannelGraph()},
SendToPeer: s.SendToPeer, SendToPeer: s.SendToPeer,
FindPeer: func(pub *btcec.PublicKey) (lnpeer.Peer, error) {
return s.FindPeer(pub)
},
NotifyWhenOnline: s.NotifyWhenOnline, NotifyWhenOnline: s.NotifyWhenOnline,
ProofMatureDelta: 0, ProofMatureDelta: 0,
TrickleDelay: time.Millisecond * time.Duration(cfg.TrickleDelay), TrickleDelay: time.Millisecond * time.Duration(cfg.TrickleDelay),
@ -1882,7 +1886,7 @@ func (s *server) addPeer(p *peer) {
// TODO(roasbeef): craft s.t. we only get updates from a few // TODO(roasbeef): craft s.t. we only get updates from a few
// peers // peers
recvUpdates := !cfg.NoChanUpdates recvUpdates := !cfg.NoChanUpdates
go s.authGossiper.InitSyncState(p.addr.IdentityKey, recvUpdates) go s.authGossiper.InitSyncState(p, recvUpdates)
// If the remote peer has the initial sync feature bit set, then we'll // If the remote peer has the initial sync feature bit set, then we'll
// being the synchronization protocol to exchange authenticated channel // being the synchronization protocol to exchange authenticated channel
@ -1892,7 +1896,7 @@ func (s *server) addPeer(p *peer) {
srvrLog.Infof("Requesting full table sync with %x", srvrLog.Infof("Requesting full table sync with %x",
p.pubKeyBytes[:]) p.pubKeyBytes[:])
go s.authGossiper.SynchronizeNode(p.addr.IdentityKey) go s.authGossiper.SynchronizeNode(p)
} }
// Check if there are listeners waiting for this peer to come online. // Check if there are listeners waiting for this peer to come online.