Publish says what it published - #22
Merged
Merged
Conversation
Each event that at least one relay accepted is printed on stdout once the relays have answered or its deadline has passed, so what publish writes out is what was published. Every answer on stderr carries the event's id, and an acceptance shows the relay's message, so a relay that already had the event says so. The exit code covers every event: 0 only when every event was accepted by at least one relay, 1 when any was not, and the rest of the stream still goes out. Before, one acceptance anywhere in the run was enough to exit 0. Events are checked before they are sent, so one whose signature does not match its content is never offered. The relays are dialled at once under the same bound as req and fetch, sent each event at once, and given one absolute deadline per event to take it and answer, 10 seconds by default and --timeout to change it. A relay still being sent to at the deadline has stopped reading and is dropped; its reader is stopped first, because a send can be waiting for the write lock behind that reader's pong rather than for the socket. Each relay has its own reader for the whole run. It answers pings, hands answers and notices over through a queue, and reports the moment its connection goes away. So an answer is counted as soon as it arrives whichever relay sends it, a relay that stalls in the middle of a message holds up only its own reader, and a relay that closed while publish waited for input is dialled again before the next event. An event sent down a connection that then closes before answering is offered once more on a fresh one, when there is time left to do it. Control characters in text a relay sends are shown as escapes, C1 included, and notices are shown up to eight per relay across its connections. More than 32 relays is refused, and req and fetch now say when they leave relays out. The help for all three says that looking up a relay's name is the one step that cannot be cut short. The nostr pin moves to 0.14.5, where pings and pongs arriving back to back no longer hold a read past its deadline. Tests drive the command against real relays on loopback: accepting, refusing, already having the event, never answering the dial, never reading, pinging while never reading, closing after an answer, pinging and then closing, closing on the next event, answering about another event, answering behind a ping or seventy notices beside twenty silent relays, sending notices or pongs without answering, notices across reconnections, and trying to forge output. CI jobs now time out at 20 minutes, so a regression that brings back an unbounded wait fails the job rather than holding a runner. Closes #19. Closes #21.
Publish says what it published.
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.
Closes #19. Closes #21.
publishprinted nothing on stdout and exited 0 when any relay accepted any event anywhere in the run, so a script publishing several events could not tell which went out. It also waited on each relay in turn for 8 seconds of silence that any message restarted, and sent an event without checking it. This changes what it returns and how it waits.What it returns
<id>: <url>: accepted,accepted (duplicate: ...),refused: <reason>,no answer within <n> ms,closed before answering), notices with the relay's URL, and ak of n publishedline when something was not.How it waits
reqandfetchnow use.--timeoutto change it. A send still going at the deadline means the relay stopped reading, so it is dropped. Its reader is stopped first, since the send can be waiting for the write lock behind that reader's pong.reqandfetchnow say when they leave relays past 32 out. The help for all three says the name lookup is the one step that cannot be cut short.The nostr pin moves to 0.14.5 (pings and pongs arriving back to back no longer hold a read past its deadline).
Tests
Twenty-two tests drive the real command against relays on loopback, one mode per behaviour in
testrelay.zig. Each of these faults, put in on its own, fails at least one of them: no signature check, printing unaccepted events, exiting 0 on any acceptance, unescaped relay text (C0, DEL and C1 separately), no resend, no redial, a stale OK counted, the notice count reset per connection. Sending to relays one after another without a bound, and joining a stuck send without stopping its reader first, each hang the suite instead of failing it; CI jobs now time out at 20 minutes so that shows up as a failure. The suite passed 15 direct runs of the test binary with no failure, the slowest 7 s.Checked live with the release build: an event nos.lol already had came back
accepted (duplicate: have this event), on stdout exactly as offered, with a silent local relay beside it dropped at 5 s.Release
The last commit bumps the version to 0.3.0 and adds its release notes.