lnwire: simplify dyn decode methods

Remove the unnecessary convertions as suggested by Gemini.
This commit is contained in:
yyforyongyu
2025-07-03 04:42:34 +08:00
parent 91797ad1d2
commit 7a9f197de8
2 changed files with 8 additions and 24 deletions

View File

@@ -110,24 +110,16 @@ func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
// Check the results of the TLV Stream decoding and appropriately set
// message fields.
if _, ok := knownRecords[dc.DustLimit.TlvType()]; ok {
var rec tlv.RecordT[tlv.TlvType0, tlv.BigSizeT[btcutil.Amount]]
rec.Val = dustLimit.Val
dc.DustLimit = tlv.SomeRecordT(rec)
dc.DustLimit = tlv.SomeRecordT(dustLimit)
}
if _, ok := knownRecords[dc.MaxValueInFlight.TlvType()]; ok {
var rec tlv.RecordT[tlv.TlvType2, MilliSatoshi]
rec.Val = maxValue.Val
dc.MaxValueInFlight = tlv.SomeRecordT(rec)
dc.MaxValueInFlight = tlv.SomeRecordT(maxValue)
}
if _, ok := knownRecords[dc.HtlcMinimum.TlvType()]; ok {
var rec tlv.RecordT[tlv.TlvType4, MilliSatoshi]
rec.Val = htlcMin.Val
dc.HtlcMinimum = tlv.SomeRecordT(rec)
dc.HtlcMinimum = tlv.SomeRecordT(htlcMin)
}
if _, ok := knownRecords[dc.ChannelReserve.TlvType()]; ok {
var rec tlv.RecordT[tlv.TlvType6, tlv.BigSizeT[btcutil.Amount]]
rec.Val = reserve.Val
dc.ChannelReserve = tlv.SomeRecordT(rec)
dc.ChannelReserve = tlv.SomeRecordT(reserve)
}
if _, ok := knownRecords[dc.CsvDelay.TlvType()]; ok {
dc.CsvDelay = tlv.SomeRecordT(csvDelay)

View File

@@ -130,27 +130,19 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
// Check the results of the TLV Stream decoding and appropriately set
// message fields.
if _, ok := knownRecords[dp.DustLimit.TlvType()]; ok {
var rec tlv.RecordT[tlv.TlvType0, tlv.BigSizeT[btcutil.Amount]]
rec.Val = dustLimit.Val
dp.DustLimit = tlv.SomeRecordT(rec)
dp.DustLimit = tlv.SomeRecordT(dustLimit)
}
if _, ok := knownRecords[dp.MaxValueInFlight.TlvType()]; ok {
var rec tlv.RecordT[tlv.TlvType2, MilliSatoshi]
rec.Val = maxValue.Val
dp.MaxValueInFlight = tlv.SomeRecordT(rec)
dp.MaxValueInFlight = tlv.SomeRecordT(maxValue)
}
if _, ok := knownRecords[dp.HtlcMinimum.TlvType()]; ok {
var rec tlv.RecordT[tlv.TlvType4, MilliSatoshi]
rec.Val = htlcMin.Val
dp.HtlcMinimum = tlv.SomeRecordT(rec)
dp.HtlcMinimum = tlv.SomeRecordT(htlcMin)
}
if _, ok := knownRecords[dp.ChannelReserve.TlvType()]; ok {
var rec tlv.RecordT[tlv.TlvType6, tlv.BigSizeT[btcutil.Amount]]
rec.Val = reserve.Val
dp.ChannelReserve = tlv.SomeRecordT(rec)
dp.ChannelReserve = tlv.SomeRecordT(reserve)
}
if _, ok := knownRecords[dp.CsvDelay.TlvType()]; ok {