Skip to main content

Module connection

Module connection 

Source
Expand description

The barkd single-instance guarantee: barkd.lock, exclusively locked for the process lifetime. The wallet’s LOCK can’t serve here, since it is only taken once a wallet is open.

Constants§

BARKD_LOCK_FILE
File in the datadir exclusively locked for the lifetime of a barkd process.
BARKD_URL_FILE
File in the datadir carrying the base URL the barkd holding the lock listens on. Only meaningful while the lock is held.

Functions§

acquire_barkd_lock
Take the exclusive barkd lock on the datadir, or fail fast when another barkd already runs there. The OS releases the lock when the returned value is dropped or the process exits, even on SIGKILL or a crash.
barkd_pid
The pid of the barkd holding the datadir lock, or None when no barkd is running there. The flock, not the file’s existence, is the liveness signal: the OS releases it the instant the holder dies.
barkd_url
The base URL recorded by the barkd on this datadir, if any.
store_barkd_url
Record the base URL this barkd listens on, so that clients on the same datadir connect to it instead of the default listen address.
wipe_datadir_except_barkd_files
Remove everything in the datadir except the running barkd’s own files, so the held lock, auth token and listen URL survive a wallet wipe.