multi: extract and pass through IsZombieChannel method

This commit is contained in:
Elle Mouton
2023-09-20 10:58:42 +02:00
parent 67df687f08
commit e12321cfd6
5 changed files with 77 additions and 25 deletions

View File

@@ -335,6 +335,11 @@ type Config struct {
// to without iterating over the entire set of open channels.
FindChannel func(node *btcec.PublicKey, chanID lnwire.ChannelID) (
*channeldb.OpenChannel, error)
// IsStillZombieChannel takes the timestamps of the latest channel
// updates for a channel and returns true if the channel should be
// considered a zombie based on these timestamps.
IsStillZombieChannel func(time.Time, time.Time) bool
}
// processedNetworkMsg is a wrapper around networkMsg and a boolean. It is
@@ -519,6 +524,7 @@ func New(cfg Config, selfKeyDesc *keychain.KeyDescriptor) *AuthenticatedGossiper
IgnoreHistoricalFilters: cfg.IgnoreHistoricalFilters,
BestHeight: gossiper.latestHeight,
PinnedSyncers: cfg.PinnedSyncers,
IsStillZombieChannel: cfg.IsStillZombieChannel,
})
gossiper.reliableSender = newReliableSender(&reliableSenderCfg{

View File

@@ -102,6 +102,11 @@ type SyncManagerCfg struct {
// ActiveSync upon connection. These peers will never transition to
// PassiveSync.
PinnedSyncers PinnedSyncers
// IsStillZombieChannel takes the timestamps of the latest channel
// updates for a channel and returns true if the channel should be
// considered a zombie based on these timestamps.
IsStillZombieChannel func(time.Time, time.Time) bool
}
// SyncManager is a subsystem of the gossiper that manages the gossip syncers
@@ -501,6 +506,7 @@ func (m *SyncManager) createGossipSyncer(peer lnpeer.Peer) *GossipSyncer {
markGraphSynced: m.markGraphSynced,
maxQueryChanRangeReplies: maxQueryChanRangeReplies,
noTimestampQueryOption: m.cfg.NoTimestampQueries,
isStillZombieChannel: m.cfg.IsStillZombieChannel,
})
// Gossip syncers are initialized by default in a PassiveSync type

View File

@@ -293,6 +293,11 @@ type gossipSyncerCfg struct {
// maxQueryChanRangeReplies is the maximum number of replies we'll allow
// for a single QueryChannelRange request.
maxQueryChanRangeReplies uint32
// isStillZombieChannel takes the timestamps of the latest channel
// updates for a channel and returns true if the channel should be
// considered a zombie based on these timestamps.
isStillZombieChannel func(time.Time, time.Time) bool
}
// GossipSyncer is a struct that handles synchronizing the channel graph state