Skip to content

Commit

Permalink
Self review
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Apr 26, 2024
1 parent 009872f commit 47b0556
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions client/cli/src/frontier_db_cmd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ type OpaqueBlock =
pub fn open_frontier_backend<Block: BlockT, C: HeaderBackend<Block>>(
client: Arc<C>,
path: PathBuf,
) -> Result<Arc<fc_db::kv::Backend<Block>>, String> {
Ok(Arc::new(fc_db::kv::Backend::<Block>::new(
) -> Result<Arc<fc_db::kv::Backend<Block, C>>, String> {
Ok(Arc::new(fc_db::kv::Backend::<Block, C>::new(
client,
&fc_db::kv::DatabaseSettings {
source: sc_client_db::DatabaseSource::RocksDb {
Expand Down
10 changes: 4 additions & 6 deletions client/db/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ where
let is_canon = 1i32;

let mut tx = self.pool().begin().await?;

let _ = sqlx::query(
"INSERT OR IGNORE INTO blocks(
ethereum_block_hash,
Expand All @@ -265,7 +264,7 @@ where
.execute(&mut *tx)
.await?;

let _ = tx.commit().await?;
tx.commit().await?;
log::debug!(target: "frontier-sql", "The genesis block information has been submitted.");
}
Some(substrate_genesis_hash)
Expand Down Expand Up @@ -342,7 +341,7 @@ where

log::trace!(
target: "frontier-sql",
"Prepared block metadata for #{block_number} ({hash:?}) canon={is_canon}",
"[Metadata] Prepared block metadata for #{block_number} ({hash:?}) canon={is_canon}",
);
Ok(BlockMetadata {
substrate_block_hash: hash,
Expand Down Expand Up @@ -517,7 +516,7 @@ where
}
.await
.map_err(|e| {
log::error!(target: "frontier-sql", "index block logs error: {e}");
log::error!(target: "frontier-sql", ": {e}");
});
// https://www.sqlite.org/pragma.html#pragma_optimize
let _ = sqlx::query("PRAGMA optimize").execute(&pool).await;
Expand Down Expand Up @@ -707,7 +706,6 @@ where
)
.fetch_one(self.pool())
.await?;

Ok(H256::from_slice(
&row.try_get::<Vec<u8>, _>(0).unwrap_or_default()[..],
))
Expand Down Expand Up @@ -931,7 +929,7 @@ impl<Block: BlockT<Hash = H256>> fc_api::LogIndexerBackend<Block> for Backend<Bl
log::debug!(target: "frontier-sql", "Sqlite progress_handler triggered for {log_key2}");
false
});
log::debug!(target: "frontier-sql", "Query in the sql backend: {sql:?} - {log_key}");
log::debug!(target: "frontier-sql", "Query: {sql:?} - {log_key}");

let mut out: Vec<FilteredLog<Block>> = vec![];
let mut rows = query.fetch(&mut *conn);
Expand Down
2 changes: 1 addition & 1 deletion client/mapping-sync/src/kv/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ mod tests {
use fc_storage::{OverrideHandle, SchemaV3Override, StorageOverride};
use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA};
use sc_block_builder::BlockBuilderProvider;
use sc_client_api::{client, BlockchainEvents};
use sc_client_api::BlockchainEvents;
use sp_api::Encode;
use sp_consensus::BlockOrigin;
use sp_core::{H160, H256, U256};
Expand Down
6 changes: 3 additions & 3 deletions client/mapping-sync/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ where
// Attempt to resume from last indexed block. If there is no data in the db, sync genesis.
match indexer_backend.last_indexed_canon_block().await.ok() {
Some(last_block_hash) => {
log::debug!(target: "frontier-sql", "===> Resume from last block {last_block_hash:?}");
log::debug!(target: "frontier-sql", "Resume from last block {last_block_hash:?}");
if let Some(parent_hash) = client
.header(last_block_hash)
.ok()
Expand Down Expand Up @@ -368,7 +368,7 @@ async fn index_canonical_block_and_ancestors<Block, Backend, Client>(
.insert_block_metadata(client.clone(), hash)
.await
.map_err(|e| {
log::error!(target: "frontier-sql", "insert block metadata {e}");
log::error!(target: "frontier-sql", "{e}");
});
indexer_backend.index_block_logs(client.clone(), hash).await;

Expand Down Expand Up @@ -420,7 +420,7 @@ async fn index_missing_blocks<Block, Client, Backend>(
} else if let Ok(Some(block_hash)) = client.hash(block_number.unique_saturated_into()) {
log::debug!(
target: "frontier-sql",
"Indexing past canonical blocks from #{} {:?}, add missing block",
"Indexing past canonical blocks from #{} {:?}",
block_number,
block_hash,
);
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ where
full: bool,
) -> RpcResult<Option<RichBlock>> {
let client = Arc::clone(&self.client);
let backend = Arc::clone(&self.backend);
let block_data_cache = Arc::clone(&self.block_data_cache);
let backend = Arc::clone(&self.backend);
let graph = Arc::clone(&self.graph);

match frontier_backend_client::native_block_id::<B, C>(
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
clippy::len_zero,
clippy::new_without_default
)]
// #![deny(unused_crate_dependencies)]
#![deny(unused_crate_dependencies)]

mod eth;
mod eth_pubsub;
Expand Down Expand Up @@ -365,8 +365,8 @@ mod tests {
fn open_frontier_backend<Block: BlockT, C: HeaderBackend<Block>>(
client: Arc<C>,
path: PathBuf,
) -> Result<Arc<fc_db::kv::Backend<Block>>, String> {
Ok(Arc::new(fc_db::kv::Backend::<Block>::new(
) -> Result<Arc<fc_db::kv::Backend<Block, C>>, String> {
Ok(Arc::new(fc_db::kv::Backend::<Block, C>::new(
client,
&fc_db::kv::DatabaseSettings {
source: sc_client_db::DatabaseSource::RocksDb {
Expand Down

0 comments on commit 47b0556

Please sign in to comment.