htlcswitch+peer: remove DecodeHopIterator from ChannelLinkConfig

In this commit, we remove the DecodeHopIterator method from the
ChannelLinkConfig struct. We do this as we no longer use this method,
since we only ever use the DecodeHopIterators method now.
This commit is contained in:
Olaoluwa Osuntokun 2018-03-12 18:43:04 -07:00
parent f2b676e93c
commit c285bb5814
4 changed files with 5 additions and 18 deletions

@ -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

@ -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) {

@ -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) {

@ -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,