Skip to content

Commit

Permalink
feat(cat-gateway): Add Mithril Snapshot Downloader control env vars (#…
Browse files Browse the repository at this point in the history
…875)

* fix(docs): Fix up docs issues

* fix(backend): Huge refactor to prep for scylladb config management

* fix(backend): Clean up logging a little, and add build info logs as required for production.

* Refactor and setup cassandra config/session

* feat(backend): Index DB schema setup seems to work

* WIP

* fix(rust): Format fixes

* fix(rust): Build fixes

* fix(rust): Adjust index DB so we can index without querying, and can optimize on first detected spend.

* fix(rust): add more docs

* fix(rust): basic new follower integration

* fix(rust): wip

* fix(ci): Bump rust compiler version to match CI

* ci(backend): Bump rust version to match CI

* fix(backend): Fix code format and lints

* feat(backend): simple new block indexer just to test the logic works

* feat(gateway): Simple indexing with cassandra seems to work

* refactor(backend): Remove lazy and once_cell in favor of new standard library replacements

* fix(backend): WIP indexing for stake addresses and unstaked ada

* fix(backend): indexing WIP

* fix(backend): Add support for log control with env vars, default to mainnet, adjust `justfile` to properly select preprod and also refresh git dependencies.

* feat(backend): Make local test scylla db run with 4 nodes, not 1

* fix(backend-lib): Add stop for cassandra db cluster

* refactor(backend-lib): Remove c509-certificate because its moved to catalyst-libs

* fix(backend): Remove dependencies from Workspace, and move into project

* fix(backend): Use temporary cat-ci branch for rust builders

* fix(backend): Remove obsolete common crates subdirectory

* fix(backend): Don't use pre-packaged mithril snapshots in integration tests

* fix(backend): Fix code so it builds with latest chain follower code.

Also eliminates redundant logic now incorporated into chain follower.

* fix(backend): Fix broken reference to catalyst libs

* ci(ci): Bump all earthfiles to latest WIP cat-ci branch

* fix(frontend-pkg): Ignore .dart_tool directory in frontend files checking markdown

* fix(ci): Fix spelling

* fix(spelling): Add more project words and properly sort list

* fix(backend): Sync rust configs and add target to make it easier in future

* fix(backend): Enable all features of Scylla for now.

* fix(frontend-pkg): Fix markdown table having too many columns

* ci(spelling): Fix spelling issues

* fix(docs): Bump docs to latest WIP cat-ci version

* feat(gateway): Add low resource scylla db instance for local testing

* feat(gateway): Add and update developer convenience functions for backend

* fix(backend): Fix code format

* fix(backend): Fix spelling issues in CQL files

* fix(spelling): Remove duplicates from the project words dictionary

* fix(backend): Get the backend building properly with earthly.

* feat(backend): remove obsoleted postgres logic for chain indexing

* revert(event-db): Revert extension changes to sql files after fixing sqlfluff version

* fix(frontend): Regenerate the dart api interface file, and add doing that to the pre-push just command

* fix(backend): temporarily disable API tests

* fix(backend): Also temporarily stop workflow consuming test reports that are disabled

* fix(ci): Try and stop coveralls running for api-tests

* ci(general): Replace temp CI branch with tagged release

* feat: Add Handler for Permissionless Auth (#825)

* docs(cips): Add Formal Defintion of auth token

* fix(docs): Fix comments in cddl file

* fix(docs): sig size

* fix(docs): Rename CDDL for the auth token

* docs(docs): Add auth-header documentation

* docs(docs): Fix markdown line length error

* docs(general): Fix spelling

* fix(backend-lib): Bump to catalyst-libs tagged version

* fix(backend): stub out obsolete code (to be removed in follow up PR).

* fix(backend-lib): code format

* fix(backend): remove unused crate dependencies

* feat: auth token (#723)

* feat(auth token encode and decode): permissionless auth

* feat(auth token encode and decode): permissionless auth

* feat(auth token encode and decode): permissionless auth

* feat(auth token encode and decode): permissionless auth

* feat(auth token encode and decode): permissionless auth

* iron out tests

* iron out tests

* refactor(auth token encode and decode): ed25519 Signature cbor fields

Sig over the preceding two fields - sig(cbor(kid), cbor(ulid))

* refactor(auth token encode and decode): ed25519 Signature cbor fields

Sig over the preceding two fields - sig(cbor(kid), cbor(ulid))

* feat(cat security scheme): open api

* feat(cat security scheme): open api

* feat(mock cert state): given kid from bearer return pub key

* feat(auth token): cache TTL

* feat(auth token): cache TTL

* feat(auth token): cache TT

* ci(spell check): fix

* ci(spell check): fix

* ci(spell check): fix

* refactor(clippy): housekeeping tidy

* refactor(clippy): housekeeping tidy

* refactor(clippy): housekeeping tidy

* refactor(clippy): housekeeping tidy

* fix(backend): Re-enable dependent crates used by this code

* fix(backend): clippy lints

* fix(backend): spelling

---------

Co-authored-by: Steven Johnson <[email protected]>
Co-authored-by: Steven Johnson <[email protected]>

* feat: Update GET staked_ada endpoint to fetch from ScyllaDB (#728)

* feat: get staked ada from scylladb

* chore: revert justfile changes

* chore: filter TXOs in rust instead of filtering in ScyllaDB query

* fix(backend): spelling

* fix(backend): Eliminate lint errors from Derived function

* fix(backend): code format

* fix(backend): Udate autogenerated dart code

* chore(cat-voices): fix tests

---------

Co-authored-by: Steven Johnson <[email protected]>
Co-authored-by: Steven Johnson <[email protected]>
Co-authored-by: Dominik Toton <[email protected]>

* feat: DB Indexing for  CIP-36 registrations (#788)

* feat: add schema for cip-36 registration tables

* feat: index cip-36 by stake address

* feat: index cip-36 registrations by vote key

* fix: use TxiInserParams::new when adding txi data

* fix: remove unused cfg attributes

* fix: refactor Cip36RegistrationInsertQuery::new

* fix(backend): Refactor queries and add multiple tables for cip36 registration indexes

* fix(backend): Cip36 Primary key is stake key. Stake Key N->1 Vote Key

* fix(backend): code format

---------

Co-authored-by: Steven Johnson <[email protected]>
Co-authored-by: Steven Johnson <[email protected]>

* docs(general): Cleanup project dictionary

* docs(spelling): Fix spelling

* fix(backend): remove obsolete clippy lint cfg

* docs(backend): Improve field documentation so its not ambiguous.

* docs(backend): Fix comment

* docs(backend): Improve comment

* fix(backend): Vote Key index logic, and update comments

* fix(backend): Earthfile needs to be executed from root of repo, to properly pick up secrets

* fix(backend): make generic saturating value converter and use it instead of type specific ones

* test(cat-gateway): Add tests for float conversion and better docs about functions limitations.

* fix(cat-gateway): Developer lints in release mode, and also refer to correct local release binary

* fix(cat-gateway): CIP36 index schema error

* fix(cat-gateway): Cip36 indexing working, improve bad cassandra query reporting.

* refactor(cat-gateway): Make settings a sub-module

* refactor(cat-gateway): Break up Envvar handling into multiple files

* refactor(cat-gateway): Fix code format

* feat(cat-gateway): Add chain-sync downloader options to cat-gateway env vars

* test(cat-gateway): Make debug logs visible in local testing

* fix(cat-gateway): Minimum timeout for mithril downloads

* test(cat-gateway): Silence gratuitous debug log in cassandra queries

* refactor(cat-gateway): Decrease verboseness of the string env var logging code

* fix(general): Bump alpine version and pin to fix missing upstream containers

* ci(general): Bump cat-ci to v3.2.07

---------

Co-authored-by: cong-or <[email protected]>
Co-authored-by: Felipe Rosa <[email protected]>
Co-authored-by: Dominik Toton <[email protected]>
Co-authored-by: Joaquín Rosales <[email protected]>
  • Loading branch information
5 people authored Sep 25, 2024
1 parent 7706275 commit e1835e0
Show file tree
Hide file tree
Showing 33 changed files with 586 additions and 502 deletions.
6 changes: 3 additions & 3 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.2.03 AS mdlint-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.2.03 AS cspell-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.2.03 AS postgresql-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.2.07 AS mdlint-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.2.07 AS cspell-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.2.07 AS postgresql-ci

FROM debian:stable-slim

Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.03 AS rust-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.07 AS rust-ci

#cspell: words rustfmt toolsets USERARCH stdcfgs

Expand Down Expand Up @@ -62,7 +62,7 @@ all-hosts-build:
package-cat-gateway:
ARG tag="latest"

FROM alpine:3.19
FROM alpine:3.20.3
WORKDIR /cat-gateway

RUN apk add --no-cache gcc bash
Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ build-cat-gateway: code-format code-lint
# Run cat-gateway natively on preprod
run-cat-gateway: build-cat-gateway
CHAIN_FOLLOWER_SYNC_TASKS="16" \
RUST_LOG="error,cat-gateway=debug,cardano_chain_follower=debug,mithril-client=debug" \
RUST_LOG="error,cat_gateway=debug,cardano_chain_follower=debug,mithril-client=debug" \
CHAIN_NETWORK="Preprod" \
./target/release/cat-gateway run --log-level debug

# Run cat-gateway natively on mainnet
run-cat-gateway-mainnet: build-cat-gateway
CHAIN_FOLLOWER_SYNC_TASKS="1" \
RUST_LOG="error,cat-gateway=debug,cardano_chain_follower=debug,mithril-client=debug" \
RUST_LOG="error,cat_gateway=debug,cardano_chain_follower=debug,mithril-client=debug" \
./target/release/cat-gateway run --log-level debug
14 changes: 9 additions & 5 deletions catalyst-gateway/bin/src/cardano/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tracing::{error, info, warn};

use crate::{
db::index::{block::index_block, session::CassandraSession},
settings::Settings,
settings::{chain_follower, Settings},
};

// pub(crate) mod cip36_registration_obsolete;
Expand All @@ -26,9 +26,13 @@ const MAX_BLOCKS_BATCH_LEN: usize = 1024;
const INDEXING_DB_READY_WAIT_INTERVAL: Duration = Duration::from_secs(1);

/// Start syncing a particular network
async fn start_sync_for(chain: Network) -> anyhow::Result<()> {
let cfg = ChainSyncConfig::default_for(chain);
info!(chain = %cfg.chain, "Starting Blockchain Sync");
async fn start_sync_for(cfg: &chain_follower::EnvVars) -> anyhow::Result<()> {
let chain = cfg.chain;
let dl_config = cfg.dl_config.clone();

let mut cfg = ChainSyncConfig::default_for(chain);
cfg.mithril_cfg = cfg.mithril_cfg.with_dl_config(dl_config);
info!(chain = %chain, "Starting Blockchain Sync");

if let Err(error) = cfg.run().await {
error!(chain=%chain, error=%error, "Failed to start chain sync task");
Expand Down Expand Up @@ -275,7 +279,7 @@ pub(crate) async fn start_followers() -> anyhow::Result<()> {
cfg.log();

// Start Syncing the blockchain, so we can consume its data as required.
start_sync_for(cfg.chain).await?;
start_sync_for(&cfg).await?;
info!(chain=%cfg.chain,"Chain Sync is started.");

tokio::spawn(async move {
Expand Down
6 changes: 3 additions & 3 deletions catalyst-gateway/bin/src/db/index/block/certs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
session::CassandraSession,
},
service::utilities::convert::from_saturating,
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// Insert TXI Query and Parameters
Expand Down Expand Up @@ -109,7 +109,7 @@ impl StakeRegistrationInsertQuery {

/// Prepare Batch of Insert TXI Index Data Queries
pub(crate) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let insert_queries = PreparedQueries::prepare_batch(
session.clone(),
Expand Down Expand Up @@ -145,7 +145,7 @@ impl CertInsertQuery {

/// Prepare Batch of Insert TXI Index Data Queries
pub(crate) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
// Note: for now we have one query, but there are many certs, and later we may have more
// to add here.
Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/bin/src/db/index/block/cip36/insert_cip36.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tracing::error;

use crate::{
db::index::queries::{PreparedQueries, SizedBatch},
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// Index Registration by Stake Address
Expand Down Expand Up @@ -82,7 +82,7 @@ impl Params {

/// Prepare Batch of Insert CIP-36 Registration Index Data Queries
pub(super) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let insert_queries = PreparedQueries::prepare_batch(
session.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tracing::error;

use crate::{
db::index::queries::{PreparedQueries, SizedBatch},
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// Index Registration by Vote Key
Expand Down Expand Up @@ -49,7 +49,7 @@ impl Params {

/// Prepare Batch of Insert CIP-36 Registration Index Data Queries
pub(super) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let insert_queries = PreparedQueries::prepare_batch(
session.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tracing::error;

use crate::{
db::index::queries::{PreparedQueries, SizedBatch},
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// Index Registration by Stake Address (Invalid Registrations)
Expand Down Expand Up @@ -99,7 +99,7 @@ impl Params {

/// Prepare Batch of Insert CIP-36 Registration Index Data Queries
pub(super) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let insert_queries = PreparedQueries::prepare_batch(
session.clone(),
Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/bin/src/db/index/block/cip36/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
queries::{FallibleQueryTasks, PreparedQuery, SizedBatch},
session::CassandraSession,
},
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// Insert CIP-36 Registration Queries
Expand All @@ -39,7 +39,7 @@ impl Cip36InsertQuery {

/// Prepare Batch of Insert Cip36 Registration Data Queries
pub(crate) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<(SizedBatch, SizedBatch, SizedBatch)> {
let insert_cip36_batch = insert_cip36::Params::prepare_batch(session, cfg).await;
let insert_cip36_invalid_batch =
Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/bin/src/db/index/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) mod txo;
use cardano_chain_follower::MultiEraBlock;
use certs::CertInsertQuery;
use cip36::Cip36InsertQuery;
use tracing::{debug, error};
use tracing::error;
use txi::TxiInsertQuery;
use txo::TxoInsertQuery;

Expand Down Expand Up @@ -75,7 +75,7 @@ pub(crate) async fn index_block(block: &MultiEraBlock) -> anyhow::Result<()> {
match handle.await {
Ok(join_res) => {
match join_res {
Ok(res) => debug!(res=?res,"Query OK"),
Ok(_res) => {}, // debug!(res=?res,"Query OK")
Err(error) => {
// IF a query fails, assume everything else is broken.
error!(error=%error,"Query Failed");
Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/bin/src/db/index/block/txi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
queries::{FallibleQueryTasks, PreparedQueries, PreparedQuery, SizedBatch},
session::CassandraSession,
},
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// Insert TXI Query and Parameters
Expand Down Expand Up @@ -54,7 +54,7 @@ impl TxiInsertQuery {

/// Prepare Batch of Insert TXI Index Data Queries
pub(crate) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let txi_insert_queries = PreparedQueries::prepare_batch(
session.clone(),
Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/bin/src/db/index/block/txo/insert_txo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tracing::error;

use crate::{
db::index::queries::{PreparedQueries, SizedBatch},
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// TXO by Stake Address Indexing query
Expand Down Expand Up @@ -54,7 +54,7 @@ impl Params {

/// Prepare Batch of Staked Insert TXO Asset Index Data Queries
pub(super) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let txo_insert_queries = PreparedQueries::prepare_batch(
session.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tracing::error;

use crate::{
db::index::queries::{PreparedQueries, SizedBatch},
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// TXO Asset by Stake Address Indexing Query
Expand Down Expand Up @@ -56,7 +56,7 @@ impl Params {

/// Prepare Batch of Staked Insert TXO Asset Index Data Queries
pub(super) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let txo_insert_queries = PreparedQueries::prepare_batch(
session.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tracing::error;

use crate::{
db::index::queries::{PreparedQueries, SizedBatch},
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// Unstaked TXO by Stake Address Indexing query
Expand Down Expand Up @@ -47,7 +47,7 @@ impl Params {

/// Prepare Batch of Staked Insert TXO Asset Index Data Queries
pub(super) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let txo_insert_queries = PreparedQueries::prepare_batch(
session.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tracing::error;

use crate::{
db::index::queries::{PreparedQueries, SizedBatch},
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// Unstaked TXO Asset by Stake Address Indexing Query
Expand Down Expand Up @@ -56,7 +56,7 @@ impl Params {

/// Prepare Batch of Staked Insert TXO Asset Index Data Queries
pub(super) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let txo_insert_queries = PreparedQueries::prepare_batch(
session.clone(),
Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/bin/src/db/index/block/txo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
session::CassandraSession,
},
service::utilities::convert::from_saturating,
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// This is used to indicate that there is no stake address.
Expand Down Expand Up @@ -52,7 +52,7 @@ impl TxoInsertQuery {

/// Prepare Batch of Insert TXI Index Data Queries
pub(crate) async fn prepare_batch(
session: &Arc<Session>, cfg: &CassandraEnvVars,
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<(SizedBatch, SizedBatch, SizedBatch, SizedBatch)> {
let txo_staked_insert_batch = insert_txo::Params::prepare_batch(session, cfg).await;
let txo_unstaked_insert_batch =
Expand Down
14 changes: 8 additions & 6 deletions catalyst-gateway/bin/src/db/index/queries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use staked_ada::{
use super::block::{
certs::CertInsertQuery, cip36::Cip36InsertQuery, txi::TxiInsertQuery, txo::TxoInsertQuery,
};
use crate::settings::{CassandraEnvVars, CASSANDRA_MIN_BATCH_SIZE};
use crate::settings::cassandra_db;

/// Batches of different sizes, prepared and ready for use.
pub(crate) type SizedBatch = SkipMap<u16, Arc<Batch>>;
Expand Down Expand Up @@ -98,7 +98,9 @@ pub(crate) type FallibleQueryTasks = Vec<tokio::task::JoinHandle<FallibleQueryRe

impl PreparedQueries {
/// Create new prepared queries for a given session.
pub(crate) async fn new(session: Arc<Session>, cfg: &CassandraEnvVars) -> anyhow::Result<Self> {
pub(crate) async fn new(
session: Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<Self> {
// We initialize like this, so that all errors preparing querys get shown before aborting.
let txi_insert_queries = TxiInsertQuery::prepare_batch(&session, cfg).await;
let all_txo_queries = TxoInsertQuery::prepare_batch(&session, cfg).await;
Expand Down Expand Up @@ -154,7 +156,7 @@ impl PreparedQueries {
/// It is necessary to do this because batches are pre-sized, they can not be dynamic.
/// Preparing the batches in advance is a very larger performance increase.
pub(crate) async fn prepare_batch(
session: Arc<Session>, query: &str, cfg: &CassandraEnvVars,
session: Arc<Session>, query: &str, cfg: &cassandra_db::EnvVars,
consistency: scylla::statement::Consistency, idempotent: bool, logged: bool,
) -> anyhow::Result<SizedBatch> {
let sized_batches: SizedBatch = SkipMap::new();
Expand All @@ -163,15 +165,15 @@ impl PreparedQueries {
// same.
let prepared = Self::prepare(session, query, consistency, idempotent).await?;

for batch_size in CASSANDRA_MIN_BATCH_SIZE..=cfg.max_batch_size {
for batch_size in cassandra_db::MIN_BATCH_SIZE..=cfg.max_batch_size {
let mut batch: Batch = Batch::new(if logged {
scylla::batch::BatchType::Logged
} else {
scylla::batch::BatchType::Unlogged
});
batch.set_consistency(consistency);
batch.set_is_idempotent(idempotent);
for _ in CASSANDRA_MIN_BATCH_SIZE..=batch_size {
for _ in cassandra_db::MIN_BATCH_SIZE..=batch_size {
batch.append_statement(prepared.clone());
}

Expand Down Expand Up @@ -208,7 +210,7 @@ impl PreparedQueries {
/// This will divide the batch into optimal sized chunks and execute them until all
/// values have been executed or the first error is encountered.
pub(crate) async fn execute_batch<T: SerializeRow + Debug>(
&self, session: Arc<Session>, cfg: Arc<CassandraEnvVars>, query: PreparedQuery,
&self, session: Arc<Session>, cfg: Arc<cassandra_db::EnvVars>, query: PreparedQuery,
values: Vec<T>,
) -> FallibleQueryResults {
let query_map = match query {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
queries::{FallibleQueryResults, PreparedQueries, PreparedQuery, SizedBatch},
session::CassandraSession,
},
settings::CassandraEnvVars,
settings::cassandra_db,
};

/// Update TXO spent query string.
Expand All @@ -37,7 +37,7 @@ pub(crate) struct UpdateTxoSpentQuery;
impl UpdateTxoSpentQuery {
/// Prepare a batch of update TXO spent queries.
pub(crate) async fn prepare_batch(
session: Arc<Session>, cfg: &CassandraEnvVars,
session: Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let update_txo_spent_queries = PreparedQueries::prepare_batch(
session.clone(),
Expand Down
Loading

0 comments on commit e1835e0

Please sign in to comment.