lnd/lnutils
Olaoluwa Osuntokun eadea00aeb lnutils: add ContextFromQuit to bridge quit channels to contexts
In this commit, we add ContextFromQuit, a utility for bridging the quit
channel shutdown pattern to context.Context-based cancellation.

Several subsystems in lnd use a plain quit <-chan struct{} for
cooperative shutdown rather than a context.Context. When those
subsystems need to await a Future[error], which uses a context for
cancellation, they need a way to derive a context that is cancelled
when the quit channel closes.

ContextFromQuit does exactly that: it returns a context tied to
context.Background() plus a cancel function, and spins up a minimal
goroutine that cancels the context as soon as quit is closed. The
returned cancel must be called (deferred at the call site) so the
goroutine exits when the enclosing operation completes normally before
shutdown.

This is a pure utility with no policy and no default timeout, so
callers remain in full control of lifetime.
2026-04-10 19:16:49 -07:00
..
chan.go multi: make linter happy 2023-03-11 23:29:41 -08:00
context.go lnutils: add ContextFromQuit to bridge quit channels to contexts 2026-04-10 19:16:49 -07:00
errors.go lnwallet: check mempool acceptance before publishing 2024-01-25 07:54:39 +08:00
fs.go lnutils: add createdir util function 2025-02-20 17:08:21 +01:00
fs_test.go lnutils: add createdir util function 2025-02-20 17:08:21 +01:00
log.go lnutil: add LogPubKey helper function 2025-04-17 17:20:09 -07:00
memory.go input: create new ScriptDesciptor interface 2023-08-22 16:33:44 -07:00
README.md multi: add lnutils to host fundamental utility functions 2023-01-19 06:38:50 +08:00
stream.go multi: add lnutils to host fundamental utility functions 2023-01-19 06:38:50 +08:00
sync_map.go multi: update linter, fix new issues 2023-06-13 11:58:33 +02:00
sync_map_bench_test.go lnutils+lntemp: move SyncMap to lnutils 2023-01-19 07:08:18 +08:00
sync_map_test.go lnutils: add unit test for SyncMap 2023-04-07 17:34:48 +08:00

lnutils

This package provides fundamental types and utility functions that can be used by all other packages.