Skip to content

Commit 7a9f197

Browse files
committed
lnwire: simplify dyn decode methods
Remove the unnecessary convertions as suggested by Gemini.
1 parent 91797ad commit 7a9f197

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

lnwire/dyn_commit.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,16 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
110110
// Check the results of the TLV Stream decoding and appropriately set
111111
// message fields.
112112
if _, ok := knownRecords[dc.DustLimit.TlvType()]; ok {
113-
var rec tlv.RecordT[tlv.TlvType0, tlv.BigSizeT[btcutil.Amount]]
114-
rec.Val = dustLimit.Val
115-
dc.DustLimit = tlv.SomeRecordT(rec)
113+
dc.DustLimit = tlv.SomeRecordT(dustLimit)
116114
}
117115
if _, ok := knownRecords[dc.MaxValueInFlight.TlvType()]; ok {
118-
var rec tlv.RecordT[tlv.TlvType2, MilliSatoshi]
119-
rec.Val = maxValue.Val
120-
dc.MaxValueInFlight = tlv.SomeRecordT(rec)
116+
dc.MaxValueInFlight = tlv.SomeRecordT(maxValue)
121117
}
122118
if _, ok := knownRecords[dc.HtlcMinimum.TlvType()]; ok {
123-
var rec tlv.RecordT[tlv.TlvType4, MilliSatoshi]
124-
rec.Val = htlcMin.Val
125-
dc.HtlcMinimum = tlv.SomeRecordT(rec)
119+
dc.HtlcMinimum = tlv.SomeRecordT(htlcMin)
126120
}
127121
if _, ok := knownRecords[dc.ChannelReserve.TlvType()]; ok {
128-
var rec tlv.RecordT[tlv.TlvType6, tlv.BigSizeT[btcutil.Amount]]
129-
rec.Val = reserve.Val
130-
dc.ChannelReserve = tlv.SomeRecordT(rec)
122+
dc.ChannelReserve = tlv.SomeRecordT(reserve)
131123
}
132124
if _, ok := knownRecords[dc.CsvDelay.TlvType()]; ok {
133125
dc.CsvDelay = tlv.SomeRecordT(csvDelay)

lnwire/dyn_propose.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,27 +130,19 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
130130
// Check the results of the TLV Stream decoding and appropriately set
131131
// message fields.
132132
if _, ok := knownRecords[dp.DustLimit.TlvType()]; ok {
133-
var rec tlv.RecordT[tlv.TlvType0, tlv.BigSizeT[btcutil.Amount]]
134-
rec.Val = dustLimit.Val
135-
dp.DustLimit = tlv.SomeRecordT(rec)
133+
dp.DustLimit = tlv.SomeRecordT(dustLimit)
136134
}
137135

138136
if _, ok := knownRecords[dp.MaxValueInFlight.TlvType()]; ok {
139-
var rec tlv.RecordT[tlv.TlvType2, MilliSatoshi]
140-
rec.Val = maxValue.Val
141-
dp.MaxValueInFlight = tlv.SomeRecordT(rec)
137+
dp.MaxValueInFlight = tlv.SomeRecordT(maxValue)
142138
}
143139

144140
if _, ok := knownRecords[dp.HtlcMinimum.TlvType()]; ok {
145-
var rec tlv.RecordT[tlv.TlvType4, MilliSatoshi]
146-
rec.Val = htlcMin.Val
147-
dp.HtlcMinimum = tlv.SomeRecordT(rec)
141+
dp.HtlcMinimum = tlv.SomeRecordT(htlcMin)
148142
}
149143

150144
if _, ok := knownRecords[dp.ChannelReserve.TlvType()]; ok {
151-
var rec tlv.RecordT[tlv.TlvType6, tlv.BigSizeT[btcutil.Amount]]
152-
rec.Val = reserve.Val
153-
dp.ChannelReserve = tlv.SomeRecordT(rec)
145+
dp.ChannelReserve = tlv.SomeRecordT(reserve)
154146
}
155147

156148
if _, ok := knownRecords[dp.CsvDelay.TlvType()]; ok {

0 commit comments

Comments
 (0)