feat: reply OK to client-published events
nostrclient never answered a client's EVENT with the NIP-01 `["OK", <id>, <accepted>, <message>]` command result. Clients built on nostr-tools and similar libraries wait for that reply before treating a publish as successful, so NWC wallet apps paired through the public endpoint reported "publish failed" even though the request had been fanned out and answered. Relay OKs now flow through the message pool like events and notices. The router tracks each EVENT a client publishes and replies exactly once: `true` as soon as any relay accepts, `false` once every relay connected at publish time has rejected it, after a 10 s timeout, or immediately when no relay is connected. OKs nobody is waiting on are dropped at the pump so the shared result map cannot grow unbounded. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
This commit is contained in:
parent
801ce44561
commit
7aa0ce14db
6 changed files with 277 additions and 4 deletions
|
|
@ -39,11 +39,13 @@ class NostrClient:
|
|||
callback_events_func=None,
|
||||
callback_notices_func=None,
|
||||
callback_eosenotices_func=None,
|
||||
callback_command_results_func=None,
|
||||
):
|
||||
while self.running:
|
||||
self._check_events(callback_events_func)
|
||||
self._check_notices(callback_notices_func)
|
||||
self._check_eos_notices(callback_eosenotices_func)
|
||||
self._check_command_results(callback_command_results_func)
|
||||
|
||||
await asyncio.sleep(0.2)
|
||||
|
||||
|
|
@ -73,3 +75,12 @@ class NostrClient:
|
|||
callback_eosenotices_func(event_msg)
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
|
||||
def _check_command_results(self, callback_command_results_func=None):
|
||||
try:
|
||||
while self.relay_manager.message_pool.has_command_results():
|
||||
result_msg = self.relay_manager.message_pool.get_command_result()
|
||||
if callback_command_results_func:
|
||||
callback_command_results_func(result_msg)
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue