chanfitness: refactor to store channels by peer

When dealing with online events, we actually need to track our events
by peer, not by channel. All we need to track channels is to have a
set of online events for a peer which at least contain those events.
This change refactors chanfitness to track by peer.
This commit is contained in:
carla
2020-09-08 13:47:18 +02:00
parent 10f9ba952e
commit e05b4a8e2e
6 changed files with 358 additions and 344 deletions

View File

@ -3536,12 +3536,17 @@ func createRPCOpenChannel(r *rpcServer, graph *channeldb.ChannelGraph,
return channel, nil
}
peer, err := route.NewVertexFromBytes(nodePub.SerializeCompressed())
if err != nil {
return nil, err
}
// Query the event store for additional information about the channel.
// Do not fail if it is not available, because there is a potential
// race between a channel being added to our node and the event store
// being notified of it.
outpoint := dbChannel.FundingOutpoint
info, err := r.server.chanEventStore.GetChanInfo(outpoint)
info, err := r.server.chanEventStore.GetChanInfo(outpoint, peer)
switch err {
// If the store does not know about the channel, we just log it.
case chanfitness.ErrChannelNotFound: