Skip to content

Indexer trait#53

Draft
zancas wants to merge 14 commits intodevfrom
indexer_trait
Draft

Indexer trait#53
zancas wants to merge 14 commits intodevfrom
indexer_trait

Conversation

@zancas
Copy link
Member

@zancas zancas commented Mar 13, 2026

Fixes: #52

When tested against zingolib all lints and (140) tests pass.

This trait-based interface is going to be very useful for mocking out calls to the indexer. I wanted it to test offline-mode.

}

impl Indexer for GrpcIndexer {
type Error = GrpcIndexerError;

Choose a reason for hiding this comment

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

I don't love that, with this approach, calls to get_info need to handle a GrpcIndexerError::SendRejected variant, for example.

Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to have per-method error enums instead?

Choose a reason for hiding this comment

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

I think so. Even an error struct per method if there's a single failure mode.


/// Trait for communicating with a Zcash chain indexer.
pub trait Indexer {
type Error;

Choose a reason for hiding this comment

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

A trait bound to the std Error here would be very good

@zancas zancas marked this pull request as draft March 13, 2026 17:31
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.

connection behavior needs to be abstracted across different specific backends, connection types need to be well defined

3 participants