Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Fixes for Explorer Endpoints #742

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Ayiga
Copy link
Member

@Ayiga Ayiga commented Nov 27, 2024

This PR:

Revisits the initial implementation of the Explorer API endpoints to try and apply some better rust-isms to the code.

Additionally, a few issues with the retrieved data have been identified and are being fixed.

The Explorer API's underlying queries are a bit cluttered around.  Additionally
they are made utilizing the `format!` macro, which could lend itself to easy
string injection. Rust's lifetimes with it's inability to use `format` with
static strings and still be a constant expression makes this somewhat difficult.
The `lazy_static` crate has been employed to make these query strings static and
available without having to worry about lifetime issues.
The transaction size currently returns the size of the overall block
instead of the individual transaction.  To address this effectively,
the `ExplorerTransaction` `trait` has been updated to require the
ability to specify the payload size of the individual transaction.
The first block is always missing time at the moment, as the query can only
compare the time to the previous row.  Since we'll always be missing the
previous row on the first entry, we end up missing the `time` for the first
entry as well.  The fix is simply to pull one more row than we want, and to
remove the first entry when the time comes.  As a result the `Vec` has
been replaced with a `VecDeque`.

Additionally the hard-coded values have been replaced with constants with
comments.
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.

1 participant