htlcswitch: Remove constructor functions for htlcPacket.

The constructor functions have no additional logic other than passing
function parameters into struct fields. Given the large function
signatures, it is more clear to directly construct the htlcPacket in
client code than call a function with lots of positional arguments.
This commit is contained in:
Jim Posen
2017-10-23 23:18:26 -07:00
committed by Olaoluwa Osuntokun
parent bead1ba31d
commit bc8d674958
4 changed files with 106 additions and 135 deletions

View File

@@ -45,58 +45,3 @@ type htlcPacket struct {
// errors inside the htlcswitch packet.
isObfuscated bool
}
// newInitPacket creates htlc switch add packet which encapsulates the add htlc
// request and additional information for proper forwarding over htlc switch.
func newInitPacket(destNode [33]byte, htlc *lnwire.UpdateAddHTLC) *htlcPacket {
return &htlcPacket{
destNode: destNode,
amount: htlc.Amount,
htlc: htlc,
}
}
// newAddPacket creates htlc switch add packet which encapsulates the add htlc
// request and additional information for proper forwarding over htlc switch.
func newAddPacket(src, dest lnwire.ShortChannelID,
htlc *lnwire.UpdateAddHTLC, e ErrorEncrypter) *htlcPacket {
return &htlcPacket{
amount: htlc.Amount,
dest: dest,
src: src,
htlc: htlc,
obfuscator: e,
}
}
// newSettlePacket creates htlc switch ack/settle packet which encapsulates the
// settle htlc request which should be created and sent back by last hope in
// htlc path.
func newSettlePacket(src lnwire.ShortChannelID, htlc *lnwire.UpdateFufillHTLC,
payHash [sha256.Size]byte, amount lnwire.MilliSatoshi) *htlcPacket {
return &htlcPacket{
src: src,
payHash: payHash,
htlc: htlc,
amount: amount,
}
}
// newFailPacket creates htlc switch fail packet which encapsulates the fail
// htlc request which propagated back to the original hope who sent the htlc
// add request if something wrong happened on the path to the final
// destination.
func newFailPacket(src lnwire.ShortChannelID, htlc *lnwire.UpdateFailHTLC,
payHash [sha256.Size]byte, amount lnwire.MilliSatoshi,
isObfuscated bool) *htlcPacket {
return &htlcPacket{
src: src,
payHash: payHash,
htlc: htlc,
amount: amount,
isObfuscated: isObfuscated,
}
}