diff --git a/htlcswitch/link.go b/htlcswitch/link.go index e84d43b1..29449542 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -3,7 +3,6 @@ package htlcswitch import ( "bytes" "fmt" - "io" "sync" "sync/atomic" "time" @@ -85,10 +84,11 @@ func ExpectedFee(f ForwardingPolicy, htlcAmt lnwire.MilliSatoshi) lnwire.MilliSa return f.BaseFee + (htlcAmt*f.FeeRate)/1000000 } -// Ticker is an interface used to wrap a time.Ticker in a struct, -// making mocking it easier. +// Ticker is an interface used to wrap a time.Ticker in a struct, making +// mocking it easier. type Ticker interface { Start() <-chan time.Time + Stop() } @@ -97,8 +97,7 @@ type BatchTicker struct { ticker *time.Ticker } -// NewBatchTicker returns a new BatchTicker that wraps the passed -// time.Ticker. +// NewBatchTicker returns a new BatchTicker that wraps the passed time.Ticker. func NewBatchTicker(t *time.Ticker) *BatchTicker { return &BatchTicker{t} } @@ -130,6 +129,7 @@ type ChannelLinkConfig struct { // Switch provides a reference to the HTLC switch, we only use this in // testing to access circuit operations not typically exposed by the // CircuitModifier. + // // TODO(conner): remove after refactoring htlcswitch testing framework. Switch *Switch @@ -138,12 +138,6 @@ type ChannelLinkConfig struct { // ChannelLink. ForwardPackets func(...*htlcPacket) chan error - // DecodeHopIterator function is responsible for decoding HTLC Sphinx - // onion blob, and creating hop iterator which will give us next - // destination of HTLC. - DecodeHopIterator func(r io.Reader, rHash []byte, - cltv uint32) (HopIterator, lnwire.FailCode) - // DecodeHopIterators facilitates batched decoding of HTLC Sphinx onion // blobs, which are then used to inform how to forward an HTLC. // NOTE: This function assumes the same set of readers and preimages are diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index 0a688845..886164d9 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -1471,7 +1471,6 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) ( Switch: aliceSwitch, Circuits: aliceSwitch.CircuitModifier(), ForwardPackets: aliceSwitch.ForwardPackets, - DecodeHopIterator: decoder.DecodeHopIterator, DecodeHopIterators: decoder.DecodeHopIterators, DecodeOnionObfuscator: func(*sphinx.OnionPacket) ( ErrorEncrypter, lnwire.FailCode) { diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go index 9ba0a676..a7f49050 100644 --- a/htlcswitch/test_utils.go +++ b/htlcswitch/test_utils.go @@ -907,7 +907,6 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel, Peer: bobServer, Circuits: aliceServer.htlcSwitch.CircuitModifier(), ForwardPackets: aliceServer.htlcSwitch.ForwardPackets, - DecodeHopIterator: aliceDecoder.DecodeHopIterator, DecodeHopIterators: aliceDecoder.DecodeHopIterators, DecodeOnionObfuscator: func(*sphinx.OnionPacket) ( ErrorEncrypter, lnwire.FailCode) { @@ -956,7 +955,6 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel, Peer: aliceServer, Circuits: bobServer.htlcSwitch.CircuitModifier(), ForwardPackets: bobServer.htlcSwitch.ForwardPackets, - DecodeHopIterator: bobDecoder.DecodeHopIterator, DecodeHopIterators: bobDecoder.DecodeHopIterators, DecodeOnionObfuscator: func(*sphinx.OnionPacket) ( ErrorEncrypter, lnwire.FailCode) { @@ -1005,7 +1003,6 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel, Peer: carolServer, Circuits: bobServer.htlcSwitch.CircuitModifier(), ForwardPackets: bobServer.htlcSwitch.ForwardPackets, - DecodeHopIterator: bobDecoder.DecodeHopIterator, DecodeHopIterators: bobDecoder.DecodeHopIterators, DecodeOnionObfuscator: func(*sphinx.OnionPacket) ( ErrorEncrypter, lnwire.FailCode) { @@ -1054,7 +1051,6 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel, Peer: bobServer, Circuits: carolServer.htlcSwitch.CircuitModifier(), ForwardPackets: carolServer.htlcSwitch.ForwardPackets, - DecodeHopIterator: carolDecoder.DecodeHopIterator, DecodeHopIterators: carolDecoder.DecodeHopIterators, DecodeOnionObfuscator: func(*sphinx.OnionPacket) ( ErrorEncrypter, lnwire.FailCode) { diff --git a/peer.go b/peer.go index cca99733..52d1bdd7 100644 --- a/peer.go +++ b/peer.go @@ -378,7 +378,6 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error { } linkCfg := htlcswitch.ChannelLinkConfig{ Peer: p, - DecodeHopIterator: p.server.sphinx.DecodeHopIterator, DecodeHopIterators: p.server.sphinx.DecodeHopIterators, DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter, GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter, @@ -1298,7 +1297,6 @@ out: } linkConfig := htlcswitch.ChannelLinkConfig{ Peer: p, - DecodeHopIterator: p.server.sphinx.DecodeHopIterator, DecodeHopIterators: p.server.sphinx.DecodeHopIterators, DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter, GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter,