Skip to content

Commit

Permalink
chore: TODO cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjasiuk committed Sep 4, 2024
1 parent 2de9794 commit a6a0452
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion chain/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
. ../.env
export TENDERMINT_URL
export DATABASE_URL
cargo run -- --initial-query-retry-time 5
cargo run
3 changes: 0 additions & 3 deletions chain/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ pub struct AppConfig {
#[clap(long, env)]
pub database_url: String,

#[clap(long, env)]
pub initial_query_retry_time: u64,

#[command(flatten)]
pub verbosity: Verbosity<InfoLevel>,
}
2 changes: 1 addition & 1 deletion chain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async fn crawling_fn(
let redelegations = query_redelegations(&client, addresses)
.await
.into_rpc_error()?;
tracing::info!("Updating bonds for {} addresses", bonds.len());
tracing::info!("Updating redelegations for {} addresses", bonds.len());

let bonds_updates = bonds
.iter()
Expand Down
53 changes: 29 additions & 24 deletions chain/src/services/namada.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,30 +570,35 @@ pub async fn query_all_redelegations(
let delegations_iter =
query_storage_prefix::<NamadaSdkEpoch>(client, &key)
.await
.context("Failed to query all delegations")
// TODO:
.unwrap()?;

let delegations = delegations_iter
.filter_map(|a| {
let (key, epoch) = a;
let delegator =
key.segments.last().expect("Delegator address");

let delegator = match delegator {
DbKeySeg::AddressSeg(delegator) => Some(delegator),
_ => None,
};

delegator.map(|delegator| Redelegation {
delegator: Id::from(delegator.clone()),
validator: validator_address.clone(),
epoch: epoch.0 as Epoch,
})
})
.collect::<Vec<_>>();

Some(delegations)
.expect("Failed to query all delegations");

match delegations_iter {
Some(delegations_iter) => {
let delegations = delegations_iter
.filter_map(|a| {
let (key, epoch) = a;
let delegator =
key.segments.last().expect("Delegator address");

let delegator = match delegator {
DbKeySeg::AddressSeg(delegator) => {
Some(delegator)
}
_ => None,
};

delegator.map(|delegator| Redelegation {
delegator: Id::from(delegator.clone()),
validator: validator_address.clone(),
epoch: epoch.0 as Epoch,
})
})
.collect::<Vec<_>>();

Some(delegations)
}
None => None,
}
})
.map(futures::future::ready)
.buffer_unordered(20)
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ services:
image: namada/chain-indexer
command: "./service \
--tendermint-url ${TENDERMINT_URL} \
--database-url ${DATABASE_URL} \
--initial-query-retry-time=15"
--database-url ${DATABASE_URL}
build:
<<: *build
args:
Expand Down
2 changes: 1 addition & 1 deletion swagger-codegen.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"npmName": "@anomaorg/namada-indexer-client",
"npmVersion": "0.0.23"
"npmVersion": "0.0.24"
}

0 comments on commit a6a0452

Please sign in to comment.