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.
This commit is contained in:
2 files changed
+9
-19
No files matched your search
+6
-11
@@ -482,16 +482,6 @@ func (c *KVStore) forEachNodeDirectedChannel(tx kvdb.RTx,
|
||||
cachedInPolicy.ToNodeFeatures = toNodeFeatures
|
||||
}
|
||||
|
||||
var inboundFee lnwire.Fee
|
||||
if p1 != nil {
|
||||
// Extract inbound fee. If there is a decoding error,
|
||||
// skip this edge.
|
||||
_, err := p1.ExtraOpaqueData.ExtractRecords(&inboundFee)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
directedChannel := &DirectedChannel{
|
||||
ChannelID: e.ChannelID,
|
||||
IsNode1: node == e.NodeKey1Bytes,
|
||||
@@ -499,7 +489,12 @@ func (c *KVStore) forEachNodeDirectedChannel(tx kvdb.RTx,
|
||||
Capacity: e.Capacity,
|
||||
OutPolicySet: p1 != nil,
|
||||
InPolicy: cachedInPolicy,
|
||||
InboundFee: inboundFee,
|
||||
}
|
||||
|
||||
if p1 != nil {
|
||||
p1.InboundFee.WhenSome(func(fee lnwire.Fee) {
|
||||
directedChannel.InboundFee = fee
|
||||
})
|
||||
}
|
||||
|
||||
if node == e.NodeKey2Bytes {
|
||||
|
||||
+3
-8
@@ -6842,7 +6842,7 @@ func marshalDBRoutingPolicy(
|
||||
disabled := policy.ChannelFlags&lnwire.ChanUpdateDisabled != 0
|
||||
|
||||
customRecords := marshalExtraOpaqueData(policy.ExtraOpaqueData)
|
||||
inboundFee := extractInboundFeeSafe(policy.ExtraOpaqueData)
|
||||
inboundFee := policy.InboundFee.UnwrapOr(lnwire.Fee{})
|
||||
|
||||
return &lnrpc.RoutingPolicy{
|
||||
TimeLockDelta: uint32(policy.TimeLockDelta),
|
||||
@@ -7698,14 +7698,9 @@ func (r *rpcServer) FeeReport(ctx context.Context,
|
||||
edgePolicy.FeeProportionalMillionths
|
||||
feeRate := float64(feeRateFixedPoint) / feeBase
|
||||
|
||||
// Decode inbound fee from extra data.
|
||||
var inboundFee lnwire.Fee
|
||||
_, err := edgePolicy.ExtraOpaqueData.ExtractRecords(
|
||||
&inboundFee,
|
||||
inboundFee := edgePolicy.InboundFee.UnwrapOr(
|
||||
lnwire.Fee{},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO(roasbeef): also add stats for revenue for each
|
||||
// channel
|
||||
|
||||
Reference in new issue
Block a user