Add relay-status CLI subcommand (closes #4)#8
Open
spcpza wants to merge 1 commit intosingularityjason:mainfrom
Open
Add relay-status CLI subcommand (closes #4)#8spcpza wants to merge 1 commit intosingularityjason:mainfrom
spcpza wants to merge 1 commit intosingularityjason:mainfrom
Conversation
Implements `lightning-memory relay-status` as requested in issue singularityjason#4. Changes: - lightning_memory/cli.py (new): relay connectivity prober and sync stats reader. Probes each configured relay concurrently using a limit:0 REQ/EOSE round-trip — lightest possible liveness check that exercises the full WebSocket + NIP-01 handshake. - lightning_memory/server.py: dispatch relay-status subcommand before starting the MCP server, so the existing entry point gains the new command without a second binary. - tests/test_relay_status.py (new): 15 tests covering _probe_relay (reachable, unreachable, NOTICE errors, latency), _sync_stats (populated DB, missing DB, empty DB), _relay_status_async (exit codes, --json output, sync stats in human output), and the server.py dispatch path. Usage: lightning-memory relay-status # human-readable lightning-memory relay-status --json # machine-readable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
lightning-memory relay-statusas requested in issue #4.Usage
Implementation
lightning_memory/cli.py(new file):_probe_relay()— sends alimit:0REQ and waits for EOSE, the lightest possible liveness check that exercises the full WS + NIP-01 handshake. All relays probed concurrently._sync_stats()— reads push/pull counts and timestamps from the local SQLitesync_log/sync_cursortables._relay_status_async()— combines both, prints human or JSON output, returns exit code 0 (all OK) or 1 (any relay unreachable).cmd_relay_status()— sync wrapper for the entry point.lightning_memory/server.py(minor patch):main()now checkssys.argvfor arelay-statussubcommand before starting the MCP server. No new binary needed — the existinglightning-memoryentry point gains the new command.tests/test_relay_status.py(new file): 15 tests covering all branches — reachable relay, unreachable relay, NOTICE error, latency measurement, DB stats (populated / missing / empty), human output, JSON output, sync stats display, and server dispatch.Exit codes
01If this is useful, sats tips are welcome: ⚡ sensiblefield821792@getalby.com