Skip to content

Commit

Permalink
various renames from CpMapping to CpSequenceNumbers
Browse files Browse the repository at this point in the history
  • Loading branch information
wlmyng committed Dec 19, 2024
1 parent 15df812 commit f961d13
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::sync::Arc;

use crate::pipeline::{concurrent::Handler, Processor};
use crate::schema::cp_mapping;
use crate::schema::cp_sequence_numbers;
use anyhow::Result;
use diesel::prelude::*;
use diesel_async::RunQueryDsl;
Expand All @@ -13,27 +13,27 @@ use sui_pg_db::{self as db};
use sui_types::full_checkpoint_content::CheckpointData;

#[derive(Insertable, Selectable, Queryable, Debug, Clone, FieldCount)]
#[diesel(table_name = cp_mapping)]
pub struct StoredCpMapping {
#[diesel(table_name = cp_sequence_numbers)]
pub struct StoredCpSequenceNumbers {
pub cp_sequence_number: i64,
pub tx_lo: i64,
pub epoch: i64,
}

pub struct CpMapping;
pub struct CpSequenceNumbers;

impl Processor for CpMapping {
const NAME: &'static str = "cp_mapping";
impl Processor for CpSequenceNumbers {
const NAME: &'static str = "cp_sequence_numbers";

type Value = StoredCpMapping;
type Value = StoredCpSequenceNumbers;

fn process(&self, checkpoint: &Arc<CheckpointData>) -> Result<Vec<Self::Value>> {
let cp_sequence_number = checkpoint.checkpoint_summary.sequence_number as i64;
let network_total_transactions =
checkpoint.checkpoint_summary.network_total_transactions as i64;
let tx_lo = network_total_transactions - checkpoint.transactions.len() as i64;
let epoch = checkpoint.checkpoint_summary.epoch as i64;
Ok(vec![StoredCpMapping {
Ok(vec![StoredCpSequenceNumbers {
cp_sequence_number,
tx_lo,
epoch,
Expand All @@ -42,9 +42,9 @@ impl Processor for CpMapping {
}

#[async_trait::async_trait]
impl Handler for CpMapping {
impl Handler for CpSequenceNumbers {
async fn commit(values: &[Self::Value], conn: &mut db::Connection<'_>) -> Result<usize> {
Ok(diesel::insert_into(cp_mapping::table)
Ok(diesel::insert_into(cp_sequence_numbers::table)
.values(values)
.on_conflict_do_nothing()
.execute(conn)
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-indexer-alt-framework/src/handlers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

pub mod cp_mapping;
pub mod cp_sequence_numbers;
4 changes: 2 additions & 2 deletions crates/sui-indexer-alt-framework/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @generated automatically by Diesel CLI.

diesel::table! {
cp_mapping (cp_sequence_number) {
cp_sequence_numbers (cp_sequence_number) {
cp_sequence_number -> Int8,
tx_lo -> Int8,
epoch -> Int8,
Expand All @@ -23,4 +23,4 @@ diesel::table! {
}
}

diesel::allow_tables_to_appear_in_same_query!(cp_mapping, watermarks,);
diesel::allow_tables_to_appear_in_same_query!(cp_sequence_numbers, watermarks,);
6 changes: 3 additions & 3 deletions crates/sui-indexer-alt/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub struct PipelineLayer {
pub coin_balance_buckets_pruner: Option<ConcurrentLayer>,

// All concurrent pipelines
pub cp_mapping: Option<ConcurrentLayer>,
pub cp_sequence_numbers: Option<ConcurrentLayer>,
pub ev_emit_mod: Option<ConcurrentLayer>,
pub ev_struct_inst: Option<ConcurrentLayer>,
pub kv_checkpoints: Option<ConcurrentLayer>,
Expand Down Expand Up @@ -274,7 +274,7 @@ impl PipelineLayer {
obj_info_pruner: Some(Default::default()),
coin_balance_buckets: Some(Default::default()),
coin_balance_buckets_pruner: Some(Default::default()),
cp_mapping: Some(Default::default()),
cp_sequence_numbers: Some(Default::default()),
ev_emit_mod: Some(Default::default()),
ev_struct_inst: Some(Default::default()),
kv_checkpoints: Some(Default::default()),
Expand Down Expand Up @@ -411,7 +411,7 @@ impl Merge for PipelineLayer {
coin_balance_buckets_pruner: self
.coin_balance_buckets_pruner
.merge(other.coin_balance_buckets_pruner),
cp_mapping: self.cp_mapping.merge(other.cp_mapping),
cp_sequence_numbers: self.cp_sequence_numbers.merge(other.cp_sequence_numbers),
ev_emit_mod: self.ev_emit_mod.merge(other.ev_emit_mod),
ev_struct_inst: self.ev_struct_inst.merge(other.ev_struct_inst),
kv_checkpoints: self.kv_checkpoints.merge(other.kv_checkpoints),
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-indexer-alt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use handlers::{
tx_affected_objects::TxAffectedObjects, tx_balance_changes::TxBalanceChanges,
tx_calls::TxCalls, tx_digests::TxDigests, tx_kinds::TxKinds,
};
use sui_indexer_alt_framework::handlers::cp_mapping::CpMapping;
use sui_indexer_alt_framework::handlers::cp_sequence_numbers::CpSequenceNumbers;
use sui_indexer_alt_framework::ingestion::{ClientArgs, IngestionConfig};
use sui_indexer_alt_framework::pipeline::{
concurrent::{ConcurrentConfig, PrunerConfig},
Expand Down Expand Up @@ -63,7 +63,7 @@ pub async fn start_indexer(
obj_info_pruner,
coin_balance_buckets,
coin_balance_buckets_pruner,
cp_mapping,
cp_sequence_numbers,
ev_emit_mod,
ev_struct_inst,
kv_checkpoints,
Expand Down Expand Up @@ -203,7 +203,7 @@ pub async fn start_indexer(
);

// Unpruned concurrent pipelines
add_concurrent!(CpMapping, cp_mapping);
add_concurrent!(CpSequenceNumbers, cp_sequence_numbers);
add_concurrent!(EvEmitMod, ev_emit_mod);
add_concurrent!(EvStructInst, ev_struct_inst);
add_concurrent!(KvCheckpoints, kv_checkpoints);
Expand Down

0 comments on commit f961d13

Please sign in to comment.