Refs #46
PR: feat/21-mempool-monitor
File: crates/charon-scanner/src/mempool.rs
Functions: MempoolMonitor::run(), run_once()
Problem
MempoolMonitor::run() and run_once() are public API methods of a library crate (charon-scanner) and return anyhow::Result<()>. This is the same recurring issue found in PRs #28, #39, and #41 and conflicts with the project convention of using thiserror for library crate error types.
Using anyhow in a library public API prevents callers from programmatically distinguishing distinct error conditions (subscription failure vs. channel closed vs. RPC transport error), makes structured retry logic impossible without string-matching error messages, and conflates internal implementation context with the public contract.
Required fix
Define a MempoolError enum:
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum MempoolError {
#[error("pending-tx subscription failed: {0}")]
SubscriptionFailed(#[source] alloy::transports::TransportError),
#[error("oracle update channel closed")]
ChannelClosed,
}
Replace anyhow::Result return types on public methods with Result<(), MempoolError>. Internal helpers may retain anyhow for convenience, converted at the public boundary.
Refs #46
PR: feat/21-mempool-monitor
File: crates/charon-scanner/src/mempool.rs
Functions: MempoolMonitor::run(), run_once()
Problem
MempoolMonitor::run() and run_once() are public API methods of a library crate (charon-scanner) and return anyhow::Result<()>. This is the same recurring issue found in PRs #28, #39, and #41 and conflicts with the project convention of using thiserror for library crate error types.
Using anyhow in a library public API prevents callers from programmatically distinguishing distinct error conditions (subscription failure vs. channel closed vs. RPC transport error), makes structured retry logic impossible without string-matching error messages, and conflates internal implementation context with the public contract.
Required fix
Define a MempoolError enum:
Replace anyhow::Result return types on public methods with Result<(), MempoolError>. Internal helpers may retain anyhow for convenience, converted at the public boundary.