peer: don't use global cfg

This commit is contained in:
Oliver Gugger 2020-05-14 14:26:07 +02:00
parent 4343f9e9a6
commit 7c1304b31c
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
2 changed files with 10 additions and 6 deletions

14
peer.go

@ -114,6 +114,8 @@ type peer struct {
started int32
disconnect int32
cfg *Config
// The following fields are only meant to be used *atomically*
bytesReceived uint64
bytesSent uint64
@ -263,7 +265,7 @@ var _ lnpeer.Peer = (*peer)(nil)
// pointer to the main server. It takes an error buffer which may contain errors
// from a previous connection with the peer if we have been connected to them
// before.
func newPeer(conn net.Conn, connReq *connmgr.ConnReq, server *server,
func newPeer(cfg *Config, conn net.Conn, connReq *connmgr.ConnReq, server *server,
addr *lnwire.NetAddress, inbound bool,
features, legacyFeatures *lnwire.FeatureVector,
chanActiveTimeout time.Duration,
@ -277,6 +279,8 @@ func newPeer(conn net.Conn, connReq *connmgr.ConnReq, server *server,
conn: conn,
addr: addr,
cfg: cfg,
activeSignal: make(chan struct{}),
inbound: inbound,
@ -651,7 +655,7 @@ func (p *peer) addLink(chanPoint *wire.OutPoint,
DecodeHopIterators: p.server.sphinx.DecodeHopIterators,
ExtractErrorEncrypter: p.server.sphinx.ExtractErrorEncrypter,
FetchLastChannelUpdate: p.server.fetchLastChanUpdate(),
HodlMask: cfg.Hodl.Mask(),
HodlMask: p.cfg.Hodl.Mask(),
Registry: p.server.invoices,
Switch: p.server.htlcSwitch,
Circuits: p.server.htlcSwitch.CircuitModifier(),
@ -671,13 +675,13 @@ func (p *peer) addLink(chanPoint *wire.OutPoint,
FwdPkgGCTicker: ticker.New(time.Minute),
PendingCommitTicker: ticker.New(time.Minute),
BatchSize: 10,
UnsafeReplay: cfg.UnsafeReplay,
UnsafeReplay: p.cfg.UnsafeReplay,
MinFeeUpdateTimeout: htlcswitch.DefaultMinLinkFeeUpdateTimeout,
MaxFeeUpdateTimeout: htlcswitch.DefaultMaxLinkFeeUpdateTimeout,
OutgoingCltvRejectDelta: p.outgoingCltvRejectDelta,
TowerClient: p.server.towerClient,
MaxOutgoingCltvExpiry: cfg.MaxOutgoingCltvExpiry,
MaxFeeAllocation: cfg.MaxChannelFeeAllocation,
MaxOutgoingCltvExpiry: p.cfg.MaxOutgoingCltvExpiry,
MaxFeeAllocation: p.cfg.MaxChannelFeeAllocation,
NotifyActiveLink: p.server.channelNotifier.NotifyActiveLinkEvent,
NotifyActiveChannel: p.server.channelNotifier.NotifyActiveChannelEvent,
NotifyInactiveChannel: p.server.channelNotifier.NotifyInactiveChannelEvent,

@ -2788,7 +2788,7 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
// htlcs, an extra block is added to prevent the channel from being
// closed when the htlc is outstanding and a new block comes in.
p, err := newPeer(
conn, connReq, s, peerAddr, inbound, initFeatures,
s.cfg, conn, connReq, s, peerAddr, inbound, initFeatures,
legacyFeatures, s.cfg.ChanEnableTimeout,
lncfg.DefaultOutgoingCltvRejectDelta, errBuffer,
)