Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcserver: remove duplicate info from RoutingPolicy #9572

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6669,12 +6669,23 @@ func marshalDBEdge(edgeInfo *models.ChannelEdgeInfo,
return edge
}

// marshalPolicyExtraOpaqueData marshals the given tlv data and filters out
// inbound fee record.
func marshalPolicyExtraOpaqueData(data []byte) map[uint64][]byte {
records := marshalExtraOpaqueData(data)

// Remove the inbound fee record as we have dedicated fields for it.
delete(records, uint64(lnwire.FeeRecordType))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we then maybe add to the CustomRecords proto field that it only includes records that we were not able to extract?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense! Will add!


return records
}

func marshalDBRoutingPolicy(
policy *models.ChannelEdgePolicy) *lnrpc.RoutingPolicy {

disabled := policy.ChannelFlags&lnwire.ChanUpdateDisabled != 0

customRecords := marshalExtraOpaqueData(policy.ExtraOpaqueData)
customRecords := marshalPolicyExtraOpaqueData(policy.ExtraOpaqueData)
inboundFee := extractInboundFeeSafe(policy.ExtraOpaqueData)

return &lnrpc.RoutingPolicy{
Expand Down Expand Up @@ -7179,7 +7190,7 @@ func marshallTopologyChange(
channelUpdates := make([]*lnrpc.ChannelEdgeUpdate, len(topChange.ChannelEdgeUpdates))
for i, channelUpdate := range topChange.ChannelEdgeUpdates {

customRecords := marshalExtraOpaqueData(
customRecords := marshalPolicyExtraOpaqueData(
channelUpdate.ExtraOpaqueData,
)
inboundFee := extractInboundFeeSafe(
Expand Down Expand Up @@ -7779,12 +7790,9 @@ func (r *rpcServer) UpdateChannelPolicy(ctx context.Context,
MinHTLC: minHtlc,
}

rpcsLog.Debugf("[updatechanpolicy] updating channel policy "+
"base_fee=%v, rate_fixed=%v, time_lock_delta: %v, "+
"min_htlc=%v, max_htlc=%v, targets=%v",
req.BaseFeeMsat, feeRateFixed, req.TimeLockDelta,
minHtlc, maxHtlc,
spew.Sdump(targetChans))
rpcsLog.Debugf("[updatechanpolicy] updating channel policy, "+
"targets=%v, req=%v", lnutils.SpewLogClosure(targetChans),
lnutils.SpewLogClosure(req))

// With the scope resolved, we'll now send this to the local channel
// manager so it can propagate the new policy for our target channel(s).
Expand Down