From 7b4c150983bc47f65080db0b6a9ca7c6451cc980 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 25 Jun 2018 20:25:21 -0700 Subject: [PATCH] htlcswitch: add new incoming+outgoing timeout fields to htlcPacket --- htlcswitch/link.go | 36 ++++++++++++++++++++---------------- htlcswitch/packet.go | 9 +++++++++ 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 6884962ce..9f801b997 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -2373,14 +2373,16 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg, chanIterator.EncodeNextHop(buf) updatePacket := &htlcPacket{ - incomingChanID: l.ShortChanID(), - incomingHTLCID: pd.HtlcIndex, - outgoingChanID: fwdInfo.NextHop, - sourceRef: pd.SourceRef, - incomingAmount: pd.Amount, - amount: addMsg.Amount, - htlc: addMsg, - obfuscator: obfuscator, + incomingChanID: l.ShortChanID(), + incomingHTLCID: pd.HtlcIndex, + outgoingChanID: fwdInfo.NextHop, + sourceRef: pd.SourceRef, + incomingAmount: pd.Amount, + amount: addMsg.Amount, + htlc: addMsg, + obfuscator: obfuscator, + incomingTimeout: pd.Timeout, + outgoingTimeout: fwdInfo.OutgoingCTLV, } switchPackets = append( switchPackets, updatePacket, @@ -2439,14 +2441,16 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg, // section. if fwdPkg.State == channeldb.FwdStateLockedIn { updatePacket := &htlcPacket{ - incomingChanID: l.ShortChanID(), - incomingHTLCID: pd.HtlcIndex, - outgoingChanID: fwdInfo.NextHop, - sourceRef: pd.SourceRef, - incomingAmount: pd.Amount, - amount: addMsg.Amount, - htlc: addMsg, - obfuscator: obfuscator, + incomingChanID: l.ShortChanID(), + incomingHTLCID: pd.HtlcIndex, + outgoingChanID: fwdInfo.NextHop, + sourceRef: pd.SourceRef, + incomingAmount: pd.Amount, + amount: addMsg.Amount, + htlc: addMsg, + obfuscator: obfuscator, + incomingTimeout: pd.Timeout, + outgoingTimeout: fwdInfo.OutgoingCTLV, } fwdPkg.FwdFilter.Set(idx) diff --git a/htlcswitch/packet.go b/htlcswitch/packet.go index 01e50d275..b6bff4719 100644 --- a/htlcswitch/packet.go +++ b/htlcswitch/packet.go @@ -80,6 +80,15 @@ type htlcPacket struct { // circuit holds a reference to an Add's circuit which is persisted in // the switch during successful forwarding. circuit *PaymentCircuit + + // incomingTimeout is the timeout that the incoming HTLC carried. This + // is the timeout of the HTLC applied to the incoming link. + incomingTimeout uint32 + + // outgoingTimeout is the timeout of the proposed outgoing HTLC. This + // will be extraced from the hop payload recevived by the incoming + // link. + outgoingTimeout uint32 } // inKey returns the circuit key used to identify the incoming htlc.