Skip to content

Commit

Permalink
Imrpove raw query client visibility
Browse files Browse the repository at this point in the history
Since it is an internal concern, we can get rid of the `get_` proxy.
  • Loading branch information
Jurshsmith committed Jan 3, 2024
1 parent f853e27 commit 7596060
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
8 changes: 4 additions & 4 deletions chaindexing/src/contract_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub trait ContractState:

async fn create<'a, S: Send + Sync + Clone>(&self, context: &EventHandlerContext<S>) {
let event = &context.event;
let client = context.get_raw_query_client();
let client = context.raw_query_client;

let state_view = self.to_view();
let table_name = Self::table_name();
Expand All @@ -93,7 +93,7 @@ pub trait ContractState:
context: &EventHandlerContext<S>,
) {
let event = &context.event;
let client = context.get_raw_query_client();
let client = context.raw_query_client;

let table_name = Self::table_name();
let state_view = self.to_complete_view(table_name, client).await;
Expand All @@ -105,7 +105,7 @@ pub trait ContractState:

async fn delete<'a, S: Send + Sync + Clone>(&self, context: &EventHandlerContext<S>) {
let event = &context.event;
let client = context.get_raw_query_client();
let client = context.raw_query_client;

let table_name = Self::table_name();
let state_view = self.to_complete_view(table_name, client).await;
Expand All @@ -128,7 +128,7 @@ pub trait ContractState:
filters: HashMap<String, String>,
context: &EventHandlerContext<S>,
) -> Vec<Self> {
let client = context.get_raw_query_client();
let client = context.raw_query_client;

let raw_query = format!(
"SELECT * FROM {table_name} WHERE {filters}",
Expand Down
1 change: 0 additions & 1 deletion chaindexing/src/contract_states/state_versions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;

pub use crate::event_handlers::EventHandlerContext;
use crate::Event;
use crate::{
ChaindexingRepo, ChaindexingRepoRawQueryTxnClient, ExecutesWithRawQuery, LoadsDataWithRawQuery,
Expand Down
1 change: 0 additions & 1 deletion chaindexing/src/contract_states/state_views.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;

pub use crate::event_handlers::EventHandlerContext;
use crate::{
ChaindexingRepo, ChaindexingRepoRawQueryTxnClient, ExecutesWithRawQuery, LoadsDataWithRawQuery,
};
Expand Down
6 changes: 1 addition & 5 deletions chaindexing/src/event_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{ChaindexingRepoRawQueryTxnClient, HasRawQueryClient};
#[derive(Clone)]
pub struct EventHandlerContext<'a, SharedState: Sync + Send + Clone> {
pub event: Event,
raw_query_client: &'a ChaindexingRepoRawQueryTxnClient<'a>,
pub(super) raw_query_client: &'a ChaindexingRepoRawQueryTxnClient<'a>,
shared_state: Option<Arc<Mutex<SharedState>>>,
}

Expand All @@ -34,10 +34,6 @@ impl<'a, SharedState: Sync + Send + Clone> EventHandlerContext<'a, SharedState>
let shared_state = shared_state.lock().await;
shared_state.clone()
}

pub(super) fn get_raw_query_client(&self) -> &'a ChaindexingRepoRawQueryTxnClient<'a> {
self.raw_query_client
}
}

#[async_trait::async_trait]
Expand Down

0 comments on commit 7596060

Please sign in to comment.