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 ( import (
"bytes" "bytes"
"fmt" "fmt"
"io"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
@ -85,10 +84,11 @@ func ExpectedFee(f ForwardingPolicy, htlcAmt lnwire.MilliSatoshi) lnwire.MilliSa
return f.BaseFee + (htlcAmt*f.FeeRate)/1000000 return f.BaseFee + (htlcAmt*f.FeeRate)/1000000
} }
// Ticker is an interface used to wrap a time.Ticker in a struct, // Ticker is an interface used to wrap a time.Ticker in a struct, making
// making mocking it easier. // mocking it easier.
type Ticker interface { type Ticker interface {
Start() <-chan time.Time Start() <-chan time.Time
Stop() Stop()
} }
@ -97,8 +97,7 @@ type BatchTicker struct {
ticker *time.Ticker ticker *time.Ticker
} }
// NewBatchTicker returns a new BatchTicker that wraps the passed // NewBatchTicker returns a new BatchTicker that wraps the passed time.Ticker.
// time.Ticker.
func NewBatchTicker(t *time.Ticker) *BatchTicker { func NewBatchTicker(t *time.Ticker) *BatchTicker {
return &BatchTicker{t} return &BatchTicker{t}
} }
@ -130,6 +129,7 @@ type ChannelLinkConfig struct {
// Switch provides a reference to the HTLC switch, we only use this in // Switch provides a reference to the HTLC switch, we only use this in
// testing to access circuit operations not typically exposed by the // testing to access circuit operations not typically exposed by the
// CircuitModifier. // CircuitModifier.
//
// TODO(conner): remove after refactoring htlcswitch testing framework. // TODO(conner): remove after refactoring htlcswitch testing framework.
Switch *Switch Switch *Switch
@ -138,12 +138,6 @@ type ChannelLinkConfig struct {
// ChannelLink. // ChannelLink.
ForwardPackets func(...*htlcPacket) chan error 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 // DecodeHopIterators facilitates batched decoding of HTLC Sphinx onion
// blobs, which are then used to inform how to forward an HTLC. // blobs, which are then used to inform how to forward an HTLC.
// NOTE: This function assumes the same set of readers and preimages are // NOTE: This function assumes the same set of readers and preimages are

@ -1471,7 +1471,6 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) (
Switch: aliceSwitch, Switch: aliceSwitch,
Circuits: aliceSwitch.CircuitModifier(), Circuits: aliceSwitch.CircuitModifier(),
ForwardPackets: aliceSwitch.ForwardPackets, ForwardPackets: aliceSwitch.ForwardPackets,
DecodeHopIterator: decoder.DecodeHopIterator,
DecodeHopIterators: decoder.DecodeHopIterators, DecodeHopIterators: decoder.DecodeHopIterators,
DecodeOnionObfuscator: func(*sphinx.OnionPacket) ( DecodeOnionObfuscator: func(*sphinx.OnionPacket) (
ErrorEncrypter, lnwire.FailCode) { ErrorEncrypter, lnwire.FailCode) {

@ -907,7 +907,6 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
Peer: bobServer, Peer: bobServer,
Circuits: aliceServer.htlcSwitch.CircuitModifier(), Circuits: aliceServer.htlcSwitch.CircuitModifier(),
ForwardPackets: aliceServer.htlcSwitch.ForwardPackets, ForwardPackets: aliceServer.htlcSwitch.ForwardPackets,
DecodeHopIterator: aliceDecoder.DecodeHopIterator,
DecodeHopIterators: aliceDecoder.DecodeHopIterators, DecodeHopIterators: aliceDecoder.DecodeHopIterators,
DecodeOnionObfuscator: func(*sphinx.OnionPacket) ( DecodeOnionObfuscator: func(*sphinx.OnionPacket) (
ErrorEncrypter, lnwire.FailCode) { ErrorEncrypter, lnwire.FailCode) {
@ -956,7 +955,6 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
Peer: aliceServer, Peer: aliceServer,
Circuits: bobServer.htlcSwitch.CircuitModifier(), Circuits: bobServer.htlcSwitch.CircuitModifier(),
ForwardPackets: bobServer.htlcSwitch.ForwardPackets, ForwardPackets: bobServer.htlcSwitch.ForwardPackets,
DecodeHopIterator: bobDecoder.DecodeHopIterator,
DecodeHopIterators: bobDecoder.DecodeHopIterators, DecodeHopIterators: bobDecoder.DecodeHopIterators,
DecodeOnionObfuscator: func(*sphinx.OnionPacket) ( DecodeOnionObfuscator: func(*sphinx.OnionPacket) (
ErrorEncrypter, lnwire.FailCode) { ErrorEncrypter, lnwire.FailCode) {
@ -1005,7 +1003,6 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
Peer: carolServer, Peer: carolServer,
Circuits: bobServer.htlcSwitch.CircuitModifier(), Circuits: bobServer.htlcSwitch.CircuitModifier(),
ForwardPackets: bobServer.htlcSwitch.ForwardPackets, ForwardPackets: bobServer.htlcSwitch.ForwardPackets,
DecodeHopIterator: bobDecoder.DecodeHopIterator,
DecodeHopIterators: bobDecoder.DecodeHopIterators, DecodeHopIterators: bobDecoder.DecodeHopIterators,
DecodeOnionObfuscator: func(*sphinx.OnionPacket) ( DecodeOnionObfuscator: func(*sphinx.OnionPacket) (
ErrorEncrypter, lnwire.FailCode) { ErrorEncrypter, lnwire.FailCode) {
@ -1054,7 +1051,6 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
Peer: bobServer, Peer: bobServer,
Circuits: carolServer.htlcSwitch.CircuitModifier(), Circuits: carolServer.htlcSwitch.CircuitModifier(),
ForwardPackets: carolServer.htlcSwitch.ForwardPackets, ForwardPackets: carolServer.htlcSwitch.ForwardPackets,
DecodeHopIterator: carolDecoder.DecodeHopIterator,
DecodeHopIterators: carolDecoder.DecodeHopIterators, DecodeHopIterators: carolDecoder.DecodeHopIterators,
DecodeOnionObfuscator: func(*sphinx.OnionPacket) ( DecodeOnionObfuscator: func(*sphinx.OnionPacket) (
ErrorEncrypter, lnwire.FailCode) { ErrorEncrypter, lnwire.FailCode) {

@ -378,7 +378,6 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
} }
linkCfg := htlcswitch.ChannelLinkConfig{ linkCfg := htlcswitch.ChannelLinkConfig{
Peer: p, Peer: p,
DecodeHopIterator: p.server.sphinx.DecodeHopIterator,
DecodeHopIterators: p.server.sphinx.DecodeHopIterators, DecodeHopIterators: p.server.sphinx.DecodeHopIterators,
DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter, DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter,
GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter, GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter,
@ -1298,7 +1297,6 @@ out:
} }
linkConfig := htlcswitch.ChannelLinkConfig{ linkConfig := htlcswitch.ChannelLinkConfig{
Peer: p, Peer: p,
DecodeHopIterator: p.server.sphinx.DecodeHopIterator,
DecodeHopIterators: p.server.sphinx.DecodeHopIterators, DecodeHopIterators: p.server.sphinx.DecodeHopIterators,
DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter, DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter,
GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter, GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter,