Repository navigation
docs(ethmonitor): add package README - #223
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| return err | ||
| } | ||
|
|
||
| go func() { |
There was a problem hiding this comment.
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 👍 / 👎.
| if err := monitor.Run(ctx); err != nil { | ||
| // Run returns when ctx is cancelled, Stop is called, or on a fatal error | ||
| } |
There was a problem hiding this comment.
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 👍 / 👎.
| | `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. | |
There was a problem hiding this comment.
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 👍 / 👎.
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:
Added/Removedevents.LatestReadyBlock,GetBlock,FeeHistory, ...).eth_getLogsresults are validated (header bloom, or receipts on chains with settled headers), the receipts fallback, and default vsStrictLogsbehaviour when a block's logs can't be confirmed.Optionswith its default.Docs only, no code changes. The usage snippet was compiled and vetted against the current package.