Skip to content

Commit

Permalink
chore: TODO cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjasiuk committed Aug 8, 2024
1 parent aa91715 commit 4acd1c6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 31 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 @@ -183,7 +183,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 addresses = block.unbond_addresses();
let unbonds = namada_service::query_unbonds(&client, addresses)
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 @@ -556,30 +556,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

0 comments on commit 4acd1c6

Please sign in to comment.