-
Notifications
You must be signed in to change notification settings - Fork 273
Fix duplicate channel_updates in auditDb when restarting #1918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -304,6 +304,10 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId | |
| log.info("refreshing channel_update due to configuration changes old={} new={}", normal.channelUpdate, candidateChannelUpdate) | ||
| candidateChannelUpdate | ||
| } | ||
|
|
||
| val hasChanged = !Announcements.areSameWithoutFlags(candidateChannelUpdate, normal.channelUpdate) | ||
| context.system.eventStream.publish(LocalChannelUpdate(self, normal.commitments.channelId, normal.shortChannelId, normal.commitments.remoteParams.nodeId, normal.channelAnnouncement, normal.channelUpdate, hasChanged, normal.commitments)) | ||
|
|
||
| // we need to periodically re-send channel updates, otherwise channel will be considered stale and get pruned by network | ||
| // we take into account the date of the last update so that we don't send superfluous updates when we restart the app | ||
| val periodicRefreshInitialDelay = Helpers.nextChannelUpdateRefresh(channelUpdate1.timestamp) | ||
|
|
@@ -1879,25 +1883,24 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId | |
| case _ => () | ||
| } | ||
|
|
||
| val previousChannelUpdate_opt = stateData match { | ||
| case data: DATA_NORMAL => Some(data.channelUpdate) | ||
| case _ => None | ||
| } | ||
|
|
||
| (state, nextState, stateData, nextStateData) match { | ||
| // ORDER MATTERS! | ||
| case (WAIT_FOR_INIT_INTERNAL, OFFLINE, _, normal: DATA_NORMAL) => | ||
| // LocalChannelUpdate is already published when restoring the channel | ||
|
||
| Logs.withMdc(diagLog)(Logs.mdc(category_opt = Some(Logs.LogCategory.CONNECTION))) { | ||
| log.debug("re-emitting channel_update={} enabled={} ", normal.channelUpdate, Announcements.isEnabled(normal.channelUpdate.channelFlags)) | ||
| } | ||
| context.system.eventStream.publish(LocalChannelUpdate(self, normal.commitments.channelId, normal.shortChannelId, normal.commitments.remoteParams.nodeId, normal.channelAnnouncement, normal.channelUpdate, previousChannelUpdate_opt, normal.commitments)) | ||
| case (_, _, d1: DATA_NORMAL, d2: DATA_NORMAL) if d1.channelUpdate == d2.channelUpdate && d1.channelAnnouncement == d2.channelAnnouncement => | ||
| // don't do anything if neither the channel_update nor the channel_announcement didn't change | ||
| () | ||
| case (WAIT_FOR_FUNDING_LOCKED | NORMAL | OFFLINE | SYNCING, NORMAL | OFFLINE, _, normal: DATA_NORMAL) => | ||
| // when we do WAIT_FOR_FUNDING_LOCKED->NORMAL or NORMAL->NORMAL or SYNCING->NORMAL or NORMAL->OFFLINE, we send out the new channel_update (most of the time it will just be to enable/disable the channel) | ||
| log.info("emitting channel_update={} enabled={} ", normal.channelUpdate, Announcements.isEnabled(normal.channelUpdate.channelFlags)) | ||
| context.system.eventStream.publish(LocalChannelUpdate(self, normal.commitments.channelId, normal.shortChannelId, normal.commitments.remoteParams.nodeId, normal.channelAnnouncement, normal.channelUpdate, previousChannelUpdate_opt, normal.commitments)) | ||
| val hasChanged = stateData match { | ||
| case data: DATA_NORMAL => !Announcements.areSameWithoutFlags(data.channelUpdate, normal.channelUpdate) | ||
| case _ => true | ||
| } | ||
| context.system.eventStream.publish(LocalChannelUpdate(self, normal.commitments.channelId, normal.shortChannelId, normal.commitments.remoteParams.nodeId, normal.channelAnnouncement, normal.channelUpdate, hasChanged, normal.commitments)) | ||
| case (_, _, _: DATA_NORMAL, _: DATA_NORMAL) => | ||
| // in any other case (e.g. OFFLINE->SYNCING) we do nothing | ||
| () | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.