tlv: remove unused error return value

This commit also modifies a previous migration. Because the change is so
limited, we don't consider this a significant risk.
This commit is contained in:
Joost Jager 2019-11-22 12:10:04 +01:00
parent 883f9e5f9a
commit 5d4ceca038
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
6 changed files with 8 additions and 34 deletions

@ -562,12 +562,7 @@ func deserializeHop(r io.Reader) (*route.Hop, error) {
tlvMap[tlvType] = rawRecordBytes tlvMap[tlvType] = rawRecordBytes
} }
tlvRecords, err := tlv.MapToRecords(tlvMap) h.TLVRecords = tlv.MapToRecords(tlvMap)
if err != nil {
return nil, err
}
h.TLVRecords = tlvRecords
return h, nil return h, nil
} }

@ -710,12 +710,7 @@ func deserializeHop(r io.Reader) (*route.Hop, error) {
h.MPP = mpp h.MPP = mpp
} }
tlvRecords, err := tlv.MapToRecords(tlvMap) h.TLVRecords = tlv.MapToRecords(tlvMap)
if err != nil {
return nil, err
}
h.TLVRecords = tlvRecords
return h, nil return h, nil
} }

@ -233,10 +233,7 @@ func (r *RouterBackend) QueryRoutes(ctx context.Context,
// If we have any TLV records destined for the final hop, then we'll // If we have any TLV records destined for the final hop, then we'll
// attempt to decode them now into a form that the router can more // attempt to decode them now into a form that the router can more
// easily manipulate. // easily manipulate.
destTlvRecords, err := tlv.MapToRecords(destTLV) destTlvRecords := tlv.MapToRecords(destTLV)
if err != nil {
return nil, err
}
// Query the channel router for a possible path to the destination that // Query the channel router for a possible path to the destination that
// can carry `in.Amt` satoshis _including_ the total fee required on // can carry `in.Amt` satoshis _including_ the total fee required on
@ -533,11 +530,7 @@ func (r *RouterBackend) extractIntentFromSendRequest(
var destTLV map[uint64][]byte var destTLV map[uint64][]byte
if len(destTLV) != 0 { if len(destTLV) != 0 {
var err error payIntent.FinalDestRecords = tlv.MapToRecords(destTLV)
payIntent.FinalDestRecords, err = tlv.MapToRecords(destTLV)
if err != nil {
return nil, err
}
} }
payIntent.PayAttemptTimeout = time.Second * payIntent.PayAttemptTimeout = time.Second *

@ -3134,13 +3134,7 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
payIntent.cltvLimit = cltvLimit payIntent.cltvLimit = cltvLimit
if len(rpcPayReq.DestTlv) != 0 { if len(rpcPayReq.DestTlv) != 0 {
var err error payIntent.destTLV = tlv.MapToRecords(rpcPayReq.DestTlv)
payIntent.destTLV, err = tlv.MapToRecords(
rpcPayReq.DestTlv,
)
if err != nil {
return payIntent, err
}
} }
validateDest := func(dest route.Vertex) error { validateDest := func(dest route.Vertex) error {

@ -219,7 +219,7 @@ func StubEncoder(v []byte) Encoder {
// MapToRecords encodes the passed TLV map as a series of regular tlv.Record // MapToRecords encodes the passed TLV map as a series of regular tlv.Record
// instances. The resulting set of records will be returned in sorted order by // instances. The resulting set of records will be returned in sorted order by
// their type. // their type.
func MapToRecords(tlvMap map[uint64][]byte) ([]Record, error) { func MapToRecords(tlvMap map[uint64][]byte) []Record {
records := make([]Record, 0, len(tlvMap)) records := make([]Record, 0, len(tlvMap))
for k, v := range tlvMap { for k, v := range tlvMap {
// We don't pass in a decoder here since we don't actually know // We don't pass in a decoder here since we don't actually know
@ -234,7 +234,7 @@ func MapToRecords(tlvMap map[uint64][]byte) ([]Record, error) {
SortRecords(records) SortRecords(records)
return records, nil return records
} }
// SortRecords is a helper function that will sort a slice of records in place // SortRecords is a helper function that will sort a slice of records in place

@ -114,10 +114,7 @@ func TestRecordMapTransformation(t *testing.T) {
spew.Sdump(mappedRecords)) spew.Sdump(mappedRecords))
} }
unmappedRecords, err := MapToRecords(mappedRecords) unmappedRecords := MapToRecords(mappedRecords)
if err != nil {
t.Fatalf("#%v: unable to unmap records: %v", i, err)
}
for i := 0; i < len(testCase.records); i++ { for i := 0; i < len(testCase.records); i++ {
if unmappedRecords[i].Type() != testCase.records[i].Type() { if unmappedRecords[i].Type() != testCase.records[i].Type() {