From f8eb2cab79c8400e7c24cf80ccbec29c7f986309 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 5 Sep 2024 16:05:44 -0500 Subject: [PATCH] m --- crates/sui-graphql-rpc/src/data.rs | 21 +++++++++---------- crates/sui-graphql-rpc/src/data/pg.rs | 20 +++++++++--------- .../src/types/chain_identifier.rs | 13 +++++++----- crates/sui-graphql-rpc/src/types/cursor.rs | 4 ++-- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/crates/sui-graphql-rpc/src/data.rs b/crates/sui-graphql-rpc/src/data.rs index dad1077fe02c83..e7126653901ee9 100644 --- a/crates/sui-graphql-rpc/src/data.rs +++ b/crates/sui-graphql-rpc/src/data.rs @@ -57,27 +57,26 @@ pub(crate) trait QueryExecutor { /// issue queries over. async fn execute<'c, T, U, E>(&self, txn: T) -> Result where - // T: FnOnce(&'a mut Self::DbConnection<'c>) -> Fut, - // 'a: 'c, - // Fut: std::future::Future> + Send + 'a, - T: for<'r> FnOnce(&'r mut Self::DbConnection<'_>) -> ScopedBoxFuture<'static, 'r, Result> + Send + 'c, + T: for<'r> FnOnce( + &'r mut Self::DbConnection<'_>, + ) -> ScopedBoxFuture<'static, 'r, Result> + + Send + + 'c, E: From + std::error::Error, T: Send + 'static, U: Send + 'static, E: Send + 'static; - // T: for<'r> FnOnce(&'r mut Self::DbConnection<'_>) -> ScopedBoxFuture<'b, 'r, Result> - // + Send, - // U: 'b, - // E: From + std::error::Error + 'b; /// Execute `txn` with repeatable reads and no phantom reads -- multiple calls to the same query /// should produce the same results. `txn` is supplied a database connection to issue queries /// over. async fn execute_repeatable<'c, T, U, E>(&self, txn: T) -> Result where - // T: FnOnce(&'a mut Self::DbConnection<'_>) -> Fut, - // Fut: std::future::Future> + Send + 'a, - T: for<'r> FnOnce(&'r mut Self::DbConnection<'_>) -> ScopedBoxFuture<'static, 'r, Result> + Send + 'c, + T: for<'r> FnOnce( + &'r mut Self::DbConnection<'_>, + ) -> ScopedBoxFuture<'static, 'r, Result> + + Send + + 'c, E: From + std::error::Error, T: Send + 'static, U: Send + 'static, diff --git a/crates/sui-graphql-rpc/src/data/pg.rs b/crates/sui-graphql-rpc/src/data/pg.rs index b7fad088e6ba0f..e662ee54884dc6 100644 --- a/crates/sui-graphql-rpc/src/data/pg.rs +++ b/crates/sui-graphql-rpc/src/data/pg.rs @@ -49,17 +49,15 @@ impl QueryExecutor for PgExecutor { async fn execute<'c, T, U, E>(&self, txn: T) -> Result where - // T: FnOnce(&'a mut Self::DbConnection<'a>) -> Fut, - // Fut: std::future::Future> + Send + 'a, - T: for<'r> FnOnce(&'r mut Self::DbConnection<'_>) -> ScopedBoxFuture<'static, 'r, Result> + Send + 'c, + T: for<'r> FnOnce( + &'r mut Self::DbConnection<'_>, + ) -> ScopedBoxFuture<'static, 'r, Result> + + Send + + 'c, E: From + std::error::Error, T: Send + 'static, U: Send + 'static, E: Send + 'static, - // T: for<'r> FnOnce(&'r mut Self::DbConnection<'_>) -> ScopedBoxFuture<'b, 'r, Result> - // + Send, - // U: 'b, - // E: From + std::error::Error + 'b, { let max_cost = self.limits.max_db_query_cost; let instant = Instant::now(); @@ -92,9 +90,11 @@ impl QueryExecutor for PgExecutor { async fn execute_repeatable<'c, T, U, E>(&self, txn: T) -> Result where - // T: FnOnce(&'a mut Self::DbConnection<'_>) -> Fut, - // Fut: std::future::Future> + Send + 'a, - T: for<'r> FnOnce(&'r mut Self::DbConnection<'_>) -> ScopedBoxFuture<'static, 'r, Result> + Send + 'c, + T: for<'r> FnOnce( + &'r mut Self::DbConnection<'_>, + ) -> ScopedBoxFuture<'static, 'r, Result> + + Send + + 'c, E: From + std::error::Error, T: Send + 'static, U: Send + 'static, diff --git a/crates/sui-graphql-rpc/src/types/chain_identifier.rs b/crates/sui-graphql-rpc/src/types/chain_identifier.rs index 41850423c04436..6cfa481ee74518 100644 --- a/crates/sui-graphql-rpc/src/types/chain_identifier.rs +++ b/crates/sui-graphql-rpc/src/types/chain_identifier.rs @@ -22,11 +22,14 @@ impl ChainIdentifier { use chain_identifier::dsl; let Some(digest_bytes) = db - .execute(move |conn| async { - conn.first(move || dsl::chain_identifier.select(dsl::checkpoint_digest)) - .await - .optional() - }.scope_boxed()) + .execute(move |conn| { + async { + conn.first(move || dsl::chain_identifier.select(dsl::checkpoint_digest)) + .await + .optional() + } + .scope_boxed() + }) .await .map_err(|e| Error::Internal(format!("Failed to fetch genesis digest: {e}")))? else { diff --git a/crates/sui-graphql-rpc/src/types/cursor.rs b/crates/sui-graphql-rpc/src/types/cursor.rs index 76ca0f9b959082..24bfa2b7ec246d 100644 --- a/crates/sui-graphql-rpc/src/types/cursor.rs +++ b/crates/sui-graphql-rpc/src/types/cursor.rs @@ -8,8 +8,8 @@ use async_graphql::{ *, }; use diesel::{ - deserialize::FromSqlRow, query_builder::QueryFragment, - sql_types::Untyped, QueryDsl, QueryResult, QuerySource, + deserialize::FromSqlRow, query_builder::QueryFragment, sql_types::Untyped, QueryDsl, + QueryResult, QuerySource, }; use diesel_async::methods::LoadQuery; use fastcrypto::encoding::{Base64, Encoding};