mirror of
https://github.com/lightningnetwork/lnd.git
synced 2026-08-13 12:32:48 +02:00
In this commit, we eliminate the three buffered chan error patterns in the discovery package and replace them with actor.Promise[error]/ actor.Future[error]. The old pattern is error-prone: if a channel is completed more than once (e.g. when a deferred message copy is re-enqueued and processed again), the second write to a capacity-1 channel blocks forever. actor.Promise.Complete() is idempotent via sync.Once, so the second call is always a safe no-op regardless of whether anyone holds a reference to the Future. Additionally, PropagateChanPolicyUpdate previously blocked on <-errChan after enqueuing a policy update with no quit-channel check, creating a latent deadlock if the gossiper shut down between enqueue and send. It now uses AwaitGossipResult with a ContextFromQuit-derived context, so shutdown is always respected. This is an atomic migration that updates all callers in the same commit so each commit builds standalone. The three main pieces are: discovery networkMsg.err chan error becomes errPromise actor.Promise[error]. chanPolicyUpdateRequest.errChan chan error becomes errPromise. syncTransitionReq.errChan chan error becomes errPromise. All ~65 sites that previously wrote to the error channel now call completeGossipResult(nMsg.errPromise, err) instead. ProcessRemoteAnnouncement and ProcessLocalAnnouncement now return actor.Future[error] instead of chan error. The capacity-2 buffer comment on ProcessRemoteAnnouncement, which was itself a workaround for the old pattern, is removed along with the TODO referencing the actor model redesign. ProcessSyncTransition in syncer.go follows the same pattern: the errChan select is replaced with AwaitGossipResult using a ContextFromQuit-derived context. funding The SendAnnouncement function type in funding.Config changes from returning chan error to returning actor.Future[error]. The call sites in addToGraph and announceChannel are updated to await the future with AwaitGossipResult, passing a context derived from f.quit via ContextFromQuit. Shutdown signals (context.Canceled and discovery.ErrGossiperShuttingDown) are both mapped to ErrFundingManagerShuttingDown via the new mapGossipError helper, which also factors out the duplicated graph-rejected / unknown-error handling. The three mock SendAnnouncement implementations in manager_test.go are updated accordingly. peer+server In peer/brontide.go, the ProcessRemoteAnnouncement call in the gossip stream handler intentionally discards the result since remote gossip messages are fire-and-forget from the peer's perspective. The old comment explaining why the chan error was unsafe to use is replaced with a note that an unawaited Future[error] carries no overhead. In server.go (applyChannelUpdate), the previous select on errChan and the quit channel is replaced with ContextFromQuit + AwaitGossipResult. |
||
|---|---|---|
| .. | ||
| release-notes-0.13.1.md | ||
| release-notes-0.13.2.md | ||
| release-notes-0.13.3.md | ||
| release-notes-0.14.0.md | ||
| release-notes-0.14.1.md | ||
| release-notes-0.14.2.md | ||
| release-notes-0.14.3.md | ||
| release-notes-0.15.0.md | ||
| release-notes-0.15.1.md | ||
| release-notes-0.15.2.md | ||
| release-notes-0.15.3.md | ||
| release-notes-0.15.4.md | ||
| release-notes-0.15.5.md | ||
| release-notes-0.16.0.md | ||
| release-notes-0.16.1.md | ||
| release-notes-0.16.2.md | ||
| release-notes-0.16.3.md | ||
| release-notes-0.17.0.md | ||
| release-notes-0.17.1.md | ||
| release-notes-0.17.3.md | ||
| release-notes-0.17.4.md | ||
| release-notes-0.18.0.md | ||
| release-notes-0.18.1.md | ||
| release-notes-0.18.2.md | ||
| release-notes-0.18.3.md | ||
| release-notes-0.18.4.md | ||
| release-notes-0.18.5.md | ||
| release-notes-0.19.0.md | ||
| release-notes-0.19.1.md | ||
| release-notes-0.19.2.md | ||
| release-notes-0.19.3.md | ||
| release-notes-0.20.0.md | ||
| release-notes-0.20.1.md | ||
| release-notes-0.21.0.md | ||
| release-notes-template.md | ||