Skip to content

Commit

Permalink
Use default formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DOBEN committed Jul 23, 2024
1 parent 2e8b8ad commit 1c58e5f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
6 changes: 6 additions & 0 deletions compliant-reward-distribution/indexer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ There are a few options to configure the indexer:
- `--db-connection` should specify your postgreSQL database connection. If not specified, the default value `host=localhost dbname=indexer user=postgres password=password port=5432` is used.

- `--log-level` specifies the maximum log level. Possible values are: `trace`, `debug`, `info`, `warn`, and `error`. If not specified, the default value `info` is used.

You can open the help menu as follows:

```console
cargo run --bin indexer -- --help
```
9 changes: 7 additions & 2 deletions compliant-reward-distribution/indexer/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ CREATE TABLE IF NOT EXISTS accounts (
zk_proof_version INT8,
-- A hash of the revealed `firstName|lastName|passportNumber` to prevent
-- claiming with different accounts for the same identity.
uniqueness_hash BYTEA
uniqueness_hash BYTEA,
-- Ensure that the ZK values are set at the same time. Either the ZK values are NULL or NOT NULL.
CHECK (
(zk_proof_valid IS NULL AND zk_proof_version IS NULL AND uniqueness_hash IS NULL) OR
(zk_proof_valid IS NOT NULL AND zk_proof_version IS NOT NULL AND uniqueness_hash IS NOT NULL)
)
);

-- Improve performance on queries for a given account_address in the accounts table.
CREATE INDEX IF NOT EXISTS accounts_index ON accounts (account_address);
-- Improve performance on queries for given pending_approvals in the accounts table.
CREATE INDEX IF NOT EXISTS pending_approval_index ON accounts (pending_approval);
CREATE INDEX IF NOT EXISTS pending_approval_index ON accounts (pending_approval);
14 changes: 6 additions & 8 deletions compliant-reward-distribution/indexer/src/bin/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,31 @@ use tokio_postgres::types::ToSql;
#[derive(Debug, clap::Parser)]
#[command(author, version, about)]
struct Args {
/// The node endpoint.
#[arg(
long = "node",
short = 'n',
help = "The node endpoint.",
default_value = "https://grpc.testnet.concordium.com:20000",
global = true,
env = "CCD_INDEXER_NODE"
)]
node_endpoint: concordium_rust_sdk::v2::Endpoint,
/// Database connection string.
// A connection string detailing the connection to the database used by the
// application.
#[arg(
long = "db-connection",
default_value = "host=localhost dbname=indexer user=postgres password=password port=5432",
help = "A connection string detailing the connection to the database used by the \
application.",
env = "CCD_INDEXER_DB_CONNECTION"
)]
db_connection: tokio_postgres::config::Config,
/// Maximum log level
/// The maximum log level. Possible values are: `trace`, `debug`, `info`,
/// `warn`, and `error`.
#[clap(
long = "log-level",
default_value = "info",
help = "The maximum log level. Possible values are: `trace`, `debug`, `info`, `warn`, and \
`error`.",
env = "CCD_INDEXER_LOG_LEVEL"
)]
log_level: tracing_subscriber::filter::LevelFilter,
log_level: tracing_subscriber::filter::LevelFilter,
}

/// A handler for storing monitored events in the database. This implements
Expand Down
10 changes: 7 additions & 3 deletions compliant-reward-distribution/indexer/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type DatabaseResult<T> = Result<T, DatabaseError>;
#[derive(Debug, Serialize)]
pub struct StoredConfiguration {
/// The genesis block hash of the network monitored.
pub genesis_block_hash: BlockHash,
pub genesis_block_hash: BlockHash,
/// The last block height that was processed.
pub latest_processed_block_height: Option<AbsoluteBlockHeight>,
}
Expand Down Expand Up @@ -61,11 +61,15 @@ pub struct Database {
}

impl From<Object> for Database {
fn from(client: Object) -> Self { Self { client } }
fn from(client: Object) -> Self {
Self { client }
}
}

impl AsRef<Object> for Database {
fn as_ref(&self) -> &Object { &self.client }
fn as_ref(&self) -> &Object {
&self.client
}
}

impl Database {
Expand Down
21 changes: 0 additions & 21 deletions compliant-reward-distribution/rustfmt.toml

This file was deleted.

0 comments on commit 1c58e5f

Please sign in to comment.