Skip to content

Commit e170ad4

Browse files
committed
graph/db+rpcserver: remove inbound fee extraction
For any call-site where we extract inbound fees from a models.ChannelEdgePolicy object that was deserialised from disk, we can now just use the new InboundFee field on the object since we know that it would have been populated at deserialisation time. Note that for all these call-sites, if a failure previously happened on decoding of the TLV stream, the error would be ignored and the edge would just be skipped. This behaviour is now still the same given how ErrParsingExtraTLVBytes is handled on the DB layer.
1 parent 8314bac commit e170ad4

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

graph/db/kv_store.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -482,24 +482,19 @@ func (c *KVStore) forEachNodeDirectedChannel(tx kvdb.RTx,
482482
cachedInPolicy.ToNodeFeatures = toNodeFeatures
483483
}
484484

485-
var inboundFee lnwire.Fee
486-
if p1 != nil {
487-
// Extract inbound fee. If there is a decoding error,
488-
// skip this edge.
489-
_, err := p1.ExtraOpaqueData.ExtractRecords(&inboundFee)
490-
if err != nil {
491-
return nil
492-
}
493-
}
494-
495485
directedChannel := &DirectedChannel{
496486
ChannelID: e.ChannelID,
497487
IsNode1: node == e.NodeKey1Bytes,
498488
OtherNode: e.NodeKey2Bytes,
499489
Capacity: e.Capacity,
500490
OutPolicySet: p1 != nil,
501491
InPolicy: cachedInPolicy,
502-
InboundFee: inboundFee,
492+
}
493+
494+
if p1 != nil {
495+
p1.InboundFee.WhenSome(func(fee lnwire.Fee) {
496+
directedChannel.InboundFee = fee
497+
})
503498
}
504499

505500
if node == e.NodeKey2Bytes {

rpcserver.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6842,7 +6842,7 @@ func marshalDBRoutingPolicy(
68426842
disabled := policy.ChannelFlags&lnwire.ChanUpdateDisabled != 0
68436843

68446844
customRecords := marshalExtraOpaqueData(policy.ExtraOpaqueData)
6845-
inboundFee := extractInboundFeeSafe(policy.ExtraOpaqueData)
6845+
inboundFee := policy.InboundFee.UnwrapOr(lnwire.Fee{})
68466846

68476847
return &lnrpc.RoutingPolicy{
68486848
TimeLockDelta: uint32(policy.TimeLockDelta),
@@ -7698,14 +7698,9 @@ func (r *rpcServer) FeeReport(ctx context.Context,
76987698
edgePolicy.FeeProportionalMillionths
76997699
feeRate := float64(feeRateFixedPoint) / feeBase
77007700

7701-
// Decode inbound fee from extra data.
7702-
var inboundFee lnwire.Fee
7703-
_, err := edgePolicy.ExtraOpaqueData.ExtractRecords(
7704-
&inboundFee,
7701+
inboundFee := edgePolicy.InboundFee.UnwrapOr(
7702+
lnwire.Fee{},
77057703
)
7706-
if err != nil {
7707-
return err
7708-
}
77097704

77107705
// TODO(roasbeef): also add stats for revenue for each
77117706
// channel

0 commit comments

Comments
 (0)