channeldb: store unknown policies in database

The commit ensures that for every channel, there will always
be two entries in the edges bucket. If the policy from one or
both ends of the channel is unknown, it is marked as such.

This allows efficient lookup of incoming edges. This is
required for backwards payment path finding.
This commit is contained in:
Joost Jager
2018-06-18 12:35:22 +02:00
committed by Olaoluwa Osuntokun
parent d2612e51bd
commit 6c918a1806
7 changed files with 322 additions and 43 deletions

View File

@@ -3733,6 +3733,12 @@ func (r *rpcServer) FeeReport(ctx context.Context,
err = selfNode.ForEachChannel(nil, func(_ *bolt.Tx, chanInfo *channeldb.ChannelEdgeInfo,
edgePolicy, _ *channeldb.ChannelEdgePolicy) error {
// Self node should always have policies for its channels.
if edgePolicy == nil {
return fmt.Errorf("no policy for outgoing channel %v ",
chanInfo.ChannelID)
}
// We'll compute the effective fee rate by converting from a
// fixed point fee rate to a floating point fee rate. The fee
// rate field in the database the amount of mSAT charged per