Browse Source

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.
master
Joost Jager 5 years ago
parent
commit
5d4ceca038
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
  1. 7
      channeldb/migration_01_to_11/payments.go
  2. 7
      channeldb/payments.go
  3. 11
      lnrpc/routerrpc/router_backend.go
  4. 8
      rpcserver.go
  5. 4
      tlv/record.go
  6. 5
      tlv/record_test.go

7
channeldb/migration_01_to_11/payments.go

@ -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
}

7
channeldb/payments.go

@ -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
}

11
lnrpc/routerrpc/router_backend.go

@ -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 *

8
rpcserver.go

@ -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 {

4
tlv/record.go

@ -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

5
tlv/record_test.go

@ -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() {

Loading…
Cancel
Save