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

@@ -85,6 +85,17 @@ func (d dbNode) ForEachChannel(cb func(ChannelEdge) error) error {
return d.node.ForEachChannel(d.tx, func(tx *bolt.Tx,
ei *channeldb.ChannelEdgeInfo, ep, _ *channeldb.ChannelEdgePolicy) error {
// Skip channels for which no outgoing edge policy is available.
//
// TODO(joostjager): Ideally the case where channels have a nil
// policy should be supported, as auto pilot is not looking at
// the policies. For now, it is not easily possible to get a
// reference to the other end LightningNode object without
// retrieving the policy.
if ep == nil {
return nil
}
pubkey, _ := ep.Node.PubKey()
edge := ChannelEdge{
Channel: Channel{