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
}
tlvRecords, err := tlv.MapToRecords(tlvMap)
if err != nil {
return nil, err
}
h.TLVRecords = tlvRecords
h.TLVRecords = tlv.MapToRecords(tlvMap)
return h, nil
}

@ -710,12 +710,7 @@ func deserializeHop(r io.Reader) (*route.Hop, error) {
h.MPP = mpp
}
tlvRecords, err := tlv.MapToRecords(tlvMap)
if err != nil {
return nil, err
}
h.TLVRecords = tlvRecords
h.TLVRecords = tlv.MapToRecords(tlvMap)
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
// attempt to decode them now into a form that the router can more
// easily manipulate.
destTlvRecords, err := tlv.MapToRecords(destTLV)
if err != nil {
return nil, err
}
destTlvRecords := tlv.MapToRecords(destTLV)
// Query the channel router for a possible path to the destination that
// can carry `in.Amt` satoshis _including_ the total fee required on
@ -533,11 +530,7 @@ func (r *RouterBackend) extractIntentFromSendRequest(
var destTLV map[uint64][]byte
if len(destTLV) != 0 {
var err error
payIntent.FinalDestRecords, err = tlv.MapToRecords(destTLV)
if err != nil {
return nil, err
}
payIntent.FinalDestRecords = tlv.MapToRecords(destTLV)
}
payIntent.PayAttemptTimeout = time.Second *

@ -3134,13 +3134,7 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
payIntent.cltvLimit = cltvLimit
if len(rpcPayReq.DestTlv) != 0 {
var err error
payIntent.destTLV, err = tlv.MapToRecords(
rpcPayReq.DestTlv,
)
if err != nil {
return payIntent, err
}
payIntent.destTLV = tlv.MapToRecords(rpcPayReq.DestTlv)
}
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
// instances. The resulting set of records will be returned in sorted order by
// their type.
func MapToRecords(tlvMap map[uint64][]byte) ([]Record, error) {
func MapToRecords(tlvMap map[uint64][]byte) []Record {
records := make([]Record, 0, len(tlvMap))
for k, v := range tlvMap {
// 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)
return records, nil
return records
}
// 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))
}
unmappedRecords, err := MapToRecords(mappedRecords)
if err != nil {
t.Fatalf("#%v: unable to unmap records: %v", i, err)
}
unmappedRecords := MapToRecords(mappedRecords)
for i := 0; i < len(testCase.records); i++ {
if unmappedRecords[i].Type() != testCase.records[i].Type() {