Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DOBEN committed Jul 23, 2024
1 parent 1c58e5f commit e988749
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compliant-reward-distribution/indexer/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS settings (
-- to mainnet while the database has indexed data from testnet or vice versa.
genesis_block_hash BYTEA NOT NULL,
-- Start block height that was indexed.
start_block_height INT8,
start_block_height INT8 NOT NULL,
-- The last block height that was processed.
latest_processed_block_height INT8
);
Expand Down
12 changes: 7 additions & 5 deletions compliant-reward-distribution/indexer/src/bin/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use concordium_rust_sdk::{
queries::BlockInfo, AbsoluteBlockHeight, BlockItemSummary,
BlockItemSummaryDetails::AccountCreation,
},
v2::{self as sdk, Client},
v2::{self as sdk, Client, QueryError},
};
use tokio_postgres::types::ToSql;

Expand Down Expand Up @@ -217,9 +217,9 @@ async fn main() -> anyhow::Result<()> {
settings.genesis_block_hash
);

// While it is possible to start the indexer and immediatly stop the indexer,
// While it is possible to start the indexer and immediately stop the indexer,
// so that the settings are set in the database but no block has been processed
// at all, this edge case is rather theoretically and should not
// at all, this edge case is rather theoretical and should not
// happen in practice (the default value here should not happen in practice).
let last_processed_block = settings
.latest_processed_block_height
Expand All @@ -245,15 +245,17 @@ async fn main() -> anyhow::Result<()> {
consensus_info.genesis_block
);

handle_indexing(endpoint, start_block, db_pool).await
handle_indexing(endpoint, start_block, db_pool)
.await
.map_err(anyhow::Error::new)
}

/// Handle indexing events.
async fn handle_indexing(
endpoint: sdk::Endpoint,
start_block: AbsoluteBlockHeight,
db_pool: DatabasePool,
) -> anyhow::Result<()> {
) -> Result<(), QueryError> {
tracing::info!("Indexing from block height {}.", start_block);

let traverse_config = indexer::TraverseConfig::new_single(endpoint, start_block);
Expand Down

0 comments on commit e988749

Please sign in to comment.