Skip to content

docs(ethmonitor): add package README - #223

Merged
taylanpince merged 2 commits into
masterfrom
docs/ethmonitor-readme
Oct 27, 2026
Merged

taylanpince merged 2 commits into
masterfrom
docs/ethmonitor-readme

Conversation

@py-zoid

@py-zoid py-zoid commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Adds ethmonitor/README.md, so the package's docs show up on GitHub and on pkg.go.dev, and links it from the package list in the root README.

It covers:

  • Usage: a minimal example that subscribes and handles Added / Removed events.
  • How it works: fetch, in-memory canonical chain, logs, in-order publish queue.
  • Events and reading chain state: what each event means, and the read methods (LatestReadyBlock, GetBlock, FeeHistory, ...).
  • Logs: how empty eth_getLogs results are validated (header bloom, or receipts on chains with settled headers), the receipts fallback, and default vs StrictLogs behaviour when a block's logs can't be confirmed.
  • Options: every field of Options with its default.
  • Restarts and snapshots, and errors.

Docs only, no code changes. The usage snippet was compiled and vetted against the current package.

@py-zoid
py-zoid marked this pull request as ready for review October 27, 2026 12:28
@py-zoid
py-zoid requested a review from a team October 27, 2026 12:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T12:30:34.962958Z 61df1c1 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 61df1c1910

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread ethmonitor/README.md
return err
}

go func() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Subscribe before starting the monitor

When using a fast local provider or catching up from StartBlockNumber, the Run goroutine can publish before the next line registers the subscription. Monitor.publish discards events whenever there are no subscribers rather than retaining them, so the consumer can permanently miss the first blocks. Register the subscription before launching Run.

Useful? React with 👍 / 👎.

Comment thread ethmonitor/README.md
Comment on lines +24 to +26
if err := monitor.Run(ctx); err != nil {
// Run returns when ctx is cancelled, Stop is called, or on a fatal error
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle monitor termination in the usage loop

When ctx is cancelled or Run returns an initialization/fatal error, this goroutine discards the result while the default UnsubscribeOnStop: false leaves sub.Done() open. The shown consumer can therefore block forever and never execute its deferred cleanup. Propagate the Run result or cancellation into the select loop, or enable automatic unsubscription.

Useful? React with 👍 / 👎.

Comment thread ethmonitor/README.md
| `CacheBackend` | nil | Shared cache for block and log payloads. In most cases, leave it nil. |
| `CacheExpiry` | 10m | Lifetime of cache entries. |
| `UnsubscribeOnStop` | false | Close all subscriptions when `Run` returns. |
| `ChainID` | from node | Set it to skip asking the node. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Describe ChainID as a fallback, not an RPC bypass

lazyInit always calls getChainID and compares the result with the configured value; it uses the configured ChainID directly only when that RPC call fails. Thus setting this option does not skip asking the node as documented, which can mislead callers trying to avoid that request. Describe it as a fallback and validation value instead.

Useful? React with 👍 / 👎.

@taylanpince
taylanpince merged commit b2728e9 into master Oct 27, 2026
14 checks passed
@taylanpince
taylanpince deleted the docs/ethmonitor-readme branch October 27, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants