chanfitness: save initial online event for channels with online peers

This commit adds an initial peer online event for channels
that have peers that are online when they are created. This
addresses a race between the peer coming online and an
existing channel being added to the event store; if the
peer comes online first, the existing channel will not have
its initial online event added.
This commit is contained in:
carla committed 2020-01-07 16:35:23 +02:00
1 parent 3aca9d24b8
commit 384c6aa1f1
2 files changed
+55 -11

No files matched your search

+6
View File
@@ -210,6 +210,12 @@ func (c *ChannelEventStore) addChannel(channelPoint wire.OutPoint,
// Create an event log for the channel.
eventLog := newEventLog(channelPoint, peer, time.Now)
// If the peer is already online, add a peer online event to record
// the starting state of the peer.
if c.peers[peer] {
eventLog.add(peerOnlineEvent)
}
c.channels[channelPoint] = eventLog
}