Skip to content

Commit b4e6a5b

Browse files
committed
server, store: Replace remaining uses of Pool.get_sync with Pool.get
1 parent 55faaee commit b4e6a5b

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/graphman/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tower-http = { workspace = true }
2121

2222
[dev-dependencies]
2323
diesel = { workspace = true }
24+
diesel-async = { workspace = true }
2425
lazy_static = { workspace = true }
2526
reqwest = { workspace = true }
2627
serde = { workspace = true }

server/graphman/tests/util/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ where
3636
}
3737

3838
async fn cleanup_graphman_command_executions_table() {
39-
use diesel::prelude::*;
39+
use diesel_async::RunQueryDsl;
4040

41-
let mut conn = PRIMARY_POOL.get_sync().await.unwrap();
41+
let mut conn = PRIMARY_POOL.get().await.unwrap();
4242

4343
diesel::sql_query("truncate table public.graphman_command_executions;")
4444
.execute(&mut conn)
45+
.await
4546
.expect("truncate is successful");
4647
}

store/postgres/src/block_store.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub mod primary {
164164
}
165165

166166
pub(super) async fn drop_chain(pool: &ConnectionPool, name: &str) -> Result<(), StoreError> {
167-
let mut conn = pool.get_sync().await?;
167+
let mut conn = pool.get().await?;
168168

169169
delete(chains::table.filter(chains::name.eq(name)))
170170
.execute(&mut conn)
@@ -427,7 +427,7 @@ impl BlockStore {
427427
let cached = match self.chain_head_cache.get(shard.as_str()) {
428428
Some(cached) => cached,
429429
None => {
430-
let mut conn = match pool.get_sync().await {
430+
let mut conn = match pool.get().await {
431431
Ok(conn) => conn,
432432
Err(StoreError::DatabaseUnavailable) => continue,
433433
Err(e) => return Err(e),
@@ -608,7 +608,7 @@ impl BlockStore {
608608
None => {}
609609
}
610610

611-
let mut conn = self.mirror.primary().get_sync().await?;
611+
let mut conn = self.mirror.primary().get().await?;
612612
let shard = self
613613
.shards
614614
.iter()
@@ -667,7 +667,7 @@ impl ChainIdStore for BlockStore {
667667

668668
// Update the master copy in the primary
669669
let primary_pool = self.pools.get(&*PRIMARY_SHARD).unwrap();
670-
let mut conn = primary_pool.get_sync().await?;
670+
let mut conn = primary_pool.get().await?;
671671

672672
diesel::update(c::table.filter(c::name.eq(chain_name.as_str())))
673673
.set((

store/postgres/src/chain_store.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,7 @@ impl ChainStore {
21312131
pub(crate) async fn set_chain_identifier(&self, ident: &ChainIdentifier) -> Result<(), Error> {
21322132
use public::ethereum_networks as n;
21332133

2134-
let mut conn = self.pool.get_sync().await?;
2134+
let mut conn = self.pool.get().await?;
21352135

21362136
diesel::update(n::table.filter(n::name.eq(&self.chain)))
21372137
.set((
@@ -2163,7 +2163,7 @@ impl ChainStore {
21632163
) -> Vec<(BlockPtr, BlockHash)> {
21642164
let mut conn = self
21652165
.pool
2166-
.get_sync()
2166+
.get()
21672167
.await
21682168
.expect("can get a database connection");
21692169

@@ -2440,7 +2440,7 @@ impl ChainStoreTrait for ChainStore {
24402440
}
24412441

24422442
async fn upsert_light_blocks(&self, blocks: &[&dyn Block]) -> Result<(), Error> {
2443-
let mut conn = self.pool.get_sync().await?;
2443+
let mut conn = self.pool.get().await?;
24442444
for block in blocks {
24452445
self.storage
24462446
.upsert_block(&mut conn, &self.chain, *block, false)
@@ -2795,7 +2795,7 @@ impl ChainStoreTrait for ChainStore {
27952795
}
27962796

27972797
async fn chain_identifier(&self) -> Result<ChainIdentifier, Error> {
2798-
let mut conn = self.pool.get_sync().await?;
2798+
let mut conn = self.pool.get().await?;
27992799
use public::ethereum_networks as n;
28002800
let (genesis_block_hash, net_version) = n::table
28012801
.select((n::genesis_block_hash, n::net_version))

store/test-store/tests/postgres/chain_head.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ fn test_clear_stale_call_cache() {
546546
let call: [u8; 6] = [1, 2, 3, 4, 5, 6];
547547
let return_value: [u8; 3] = [7, 8, 9];
548548

549-
let mut conn = PRIMARY_POOL.get_sync().await.unwrap();
549+
let mut conn = PRIMARY_POOL.get().await.unwrap();
550550

551551
// Insert a call cache entry, otherwise it will hit an early return and won't test all queries
552552
let call = call::Request::new(address, call.to_vec(), 0);

0 commit comments

Comments
 (0)