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

pindexer: implement override for hardcoded values in app views #4936

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/bin/pindexer/src/dex_ex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ mod summary {
now AS (
SELECT price, liquidity
FROM snapshots
WHERE time >= $3
ORDER BY time ASC
WHERE time <= $3
ORDER BY time DESC
LIMIT 1
),
sums AS (
Expand Down
24 changes: 7 additions & 17 deletions crates/bin/pindexer/src/indexer_ext.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
use std::str::FromStr;

pub trait IndexerExt: Sized {
fn with_default_penumbra_app_views(self) -> Self;
fn with_default_penumbra_app_views(self, options: &crate::Options) -> Self;
}

impl IndexerExt for cometindex::Indexer {
fn with_default_penumbra_app_views(self) -> Self {
fn with_default_penumbra_app_views(self, options: &crate::Options) -> Self {
self.with_index(Box::new(crate::block::Block {}))
.with_index(Box::new(crate::stake::ValidatorSet {}))
.with_index(Box::new(crate::stake::Slashings {}))
.with_index(Box::new(crate::stake::DelegationTxs {}))
.with_index(Box::new(crate::stake::UndelegationTxs {}))
.with_index(Box::new(crate::governance::GovernanceProposals {}))
.with_index(Box::new(crate::dex_ex::Component::new(
penumbra_asset::asset::Id::from_str(
// USDC
"passet1w6e7fvgxsy6ccy3m8q0eqcuyw6mh3yzqu3uq9h58nu8m8mku359spvulf6",
)
.expect("should be able to parse passet"),
100.0 * 1000_0000.0,
options.indexing_denom,
options.dex_ex_min_liquidity as f64,
)))
.with_index(Box::new(crate::supply::Component::new()))
.with_index(Box::new(crate::ibc::Component::new()))
.with_index(Box::new(crate::insights::Component::new(
penumbra_asset::asset::Id::from_str(
// USDC
"passet1w6e7fvgxsy6ccy3m8q0eqcuyw6mh3yzqu3uq9h58nu8m8mku359spvulf6",
)
.ok(),
)))
.with_index(Box::new(crate::insights::Component::new(Some(
options.indexing_denom,
))))
}
}
18 changes: 17 additions & 1 deletion crates/bin/pindexer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pub use cometindex::{opt::Options, AppView, ContextualizedEvent, Indexer, PgPool, PgTransaction};
pub use cometindex::{AppView, ContextualizedEvent, Indexer, PgPool, PgTransaction};

mod indexer_ext;
pub use indexer_ext::IndexerExt;
use penumbra_asset::asset;
pub mod block;
pub mod dex_ex;
pub mod ibc;
Expand All @@ -11,3 +12,18 @@ pub mod stake;
pub mod supply;

pub mod governance;

#[derive(clap::Parser, Clone, Debug)]
pub struct Options {
#[clap(flatten)]
pub cometindex: cometindex::opt::Options,
/// The denom to use for indexing related components, of the form passet1...
#[clap(
long,
default_value = "passet1w6e7fvgxsy6ccy3m8q0eqcuyw6mh3yzqu3uq9h58nu8m8mku359spvulf6"
)]
pub indexing_denom: asset::Id,
/// The minimum liquidity for the indexing denom in the dex explorer app view.
#[clap(long, default_value = "100000000")]
pub dex_ex_min_liquidity: u128,
}
5 changes: 3 additions & 2 deletions crates/bin/pindexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use pindexer::{Indexer, IndexerExt as _, Options};

#[tokio::main]
async fn main() -> Result<()> {
Indexer::new(Options::parse())
let opts = Options::parse();
Indexer::new(opts.cometindex.clone())
.with_default_tracing()
.with_default_penumbra_app_views()
.with_default_penumbra_app_views(&opts)
.run()
.await?;

Expand Down
Loading