Repository navigation
broadcaster: /pool_status, a pin switch, and the last block in snapshots - #95
Merged
Merged
Conversation
Three additions to the broadcaster. BROADCASTER_LIVE_PIN=0 posts the live message without pinning it. A bot that may post in a group but not pin (a plain member of a forum group, for example) otherwise logs "not enough rights to manage pinned messages" on every new live message. Default 1, so nothing changes unless it is set. BROADCASTER_COMMANDS=1 answers /pool_status in TELEGRAM_CHAT_ID with the current stats, as a reply in the topic it was typed in. lib/commands.js runs its own getUpdates long poll beside the poster, so a held poll never delays a post and a failure there never stops one. getUpdates bypasses the send queue for the same reason. Details: - Only the configured chat is answered (numeric id or @username), so adding the bot elsewhere does not make it reply there. - "/pool_status@other_bot" is ignored. - At most one reply per chat per BROADCASTER_COMMAND_COOLDOWN_SEC (default 30). - The command is registered in the bot's "/" menu, because a bot in privacy mode only reliably sees the addressed "/pool_status@bot" form a menu tap sends. - The first start skips the backlog. The offset is kept in broadcaster.json, so a restart answers nothing twice. - A dashboard failure gets a short "can't be read right now" reply. - Startup failures are retried rather than switching the command off. - Off under BROADCASTER_DRY_RUN, which has no bot to read with. The live message, the periodic update and the /pool_status reply now show "Last block: #<height> · <age> ago": the newest pending or confirmed block, never an orphaned or rejected one. index.js now builds one state object and one persist() for both loops, so neither can save over the other with a stale copy. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The stat block shared by the digest, the live message, the periodic update and /pool_status now leads with the current rate, the dashboard's 5-minute hashrate_5m: Hashrate now: 3.33 PH/s (5m) Hashrate: 2.33 PH/s (1h) · 2.00 PH/s (24h) The shares line gives the rejected count beside the accepted one, keeping the rate: Shares (24h): 34,763 accepted · 76 rejected (0.22%) Both fields were already in /api/status. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Why
Running the broadcaster in a team forum group (pool.beta.avonpool.xyz posting to a topic, #94) turned up three gaps:
BROADCASTER_LIVE=1then logsnot enough rights to manage pinned messageson every new live message, and there was no way to keep the message without the pin attempt.What
BROADCASTER_LIVE_PIN=0posts and edits the live message without pinning it. The default is1, so existing setups are unchanged.BROADCASTER_COMMANDS=1answers/pool_statuswith the current stats, as a reply in the topic where it was typed. It is off by default.lib/commands.jsruns its owngetUpdateslong poll beside the poster. The long poll bypasses the send queue, so a held poll never delays a post, and a failure in it never stops the posts.TELEGRAM_CHAT_ID(numeric id or@username)./pool_status@another_botis ignored.BROADCASTER_COMMAND_COOLDOWN_SEC(default 30).setMyCommands. A bot in privacy mode reliably sees only the addressed/pool_status@botform, which is what a tap in the menu sends.broadcaster.json, so a restart answers nothing twice.BROADCASTER_DRY_RUN, which has no bot to read with.Last block line. The live message, the periodic update and the
/pool_statusreply now showLast block: #970,851 · 1h 39m ago. This is the newest pending or confirmed block, never an orphaned or rejected one.Current hashrate and share counts (second commit). The stat block shared by the digest, the live message, the periodic update and
/pool_statusnow leads with the 5-minute rate, and gives the rejected count beside the accepted one:index.jsnow builds one state object and onepersist()shared by both loops, so neither can save over the other with a stale copy.Docs: the README has a new
/pool_statussection covering privacy mode and the one-getUpdates-reader-per-bot rule, and the config table is updated..env.example,docker-compose.ymland the systemd unit comments are updated too.Tests
npm testinbroadcaster/: 33 pass, 12 of them new.@usernamematching; cooldown; reply when the dashboard fails.LIVE_PIN=0; the last block line skips orphaned blocks.getUpdatesis not queued behind posts.A
/pool_statusreply, rendered from pool.beta.avonpool.xyz's live API:🤖 Generated with Claude Code