Skip to content

Commit

Permalink
fix clippy warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanYuan committed Mar 14, 2024
1 parent e05e703 commit 5dd4901
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
11 changes: 5 additions & 6 deletions util/rich-indexer/src/indexer/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ pub(crate) async fn bulk_insert_tx_association_cell_dep_table(
tx_association_cell_dep_rows.push(vec![
tx_id.into(),
output_id.into(),
(u8::try_from(cell_dep.dep_type()).expect("cell_dep to u8 should be OK") as i16)
.into(),
(u8::from(cell_dep.dep_type()) as i16).into(),
]);
}
}
Expand Down Expand Up @@ -521,13 +520,13 @@ pub(crate) fn build_output_cell_rows(
cell_capacity as i64,
(
cell.lock().code_hash().raw_data().to_vec(),
u8::try_from(cell.lock().hash_type()).expect("hash_type to u8 should be OK") as i16,
u8::from(cell.lock().hash_type()) as i16,
cell.lock().args().raw_data().to_vec(),
),
(cell.type_().to_opt().map(|type_script| {
(
type_script.code_hash().raw_data().to_vec(),
u8::try_from(type_script.hash_type()).expect("hash_type to u8 should be OK") as i16,
u8::from(type_script.hash_type()) as i16,
type_script.args().raw_data().to_vec(),
)
})),
Expand All @@ -543,15 +542,15 @@ pub(crate) async fn build_script_set(
let lock_script = cell.lock();
let lock_script_row = (
lock_script.code_hash().raw_data().to_vec(),
u8::try_from(lock_script.hash_type()).expect("hash_type to u8 should be OK") as i16,
u8::from(lock_script.hash_type()) as i16,
lock_script.args().raw_data().to_vec(),
);
script_row.insert(lock_script_row);

if let Some(type_script) = cell.type_().to_opt() {
let type_script_row = (
type_script.code_hash().raw_data().to_vec(),
u8::try_from(type_script.hash_type()).expect("hash_type to u8 should be OK") as i16,
u8::from(type_script.hash_type()) as i16,
type_script.args().raw_data().to_vec(),
);
script_row.insert(type_script_row);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub async fn get_tx_with_cell(
) -> Result<Vec<(i64, u64, u32, Vec<u8>, u16, u32)>, Error> {
let sql_union = build_tx_with_cell_union_sub_query(db_driver, &search_key)?;

let mut query_builder = SqlBuilder::select_from(&format!("{} AS res", sql_union));
let mut query_builder = SqlBuilder::select_from(format!("{} AS res", sql_union));
query_builder.field("tx_id, block.block_number, ckb_transaction.tx_index, ckb_transaction.tx_hash, io_type, io_index");
query_builder
.join("ckb_transaction")
Expand Down Expand Up @@ -254,7 +254,7 @@ pub async fn get_tx_with_cells(
) -> Result<Vec<(i64, u64, u32, Vec<u8>, Vec<(u16, u32)>)>, Error> {
let sql_union = build_tx_with_cell_union_sub_query(db_driver, &search_key)?;

let mut query_builder = SqlBuilder::select_from(&format!("{} AS res_union", sql_union));
let mut query_builder = SqlBuilder::select_from(format!("{} AS res_union", sql_union));
query_builder
.field("tx_id, block.block_number, ckb_transaction.tx_index, ckb_transaction.tx_hash, io_type, io_index")
.join("ckb_transaction")
Expand All @@ -274,7 +274,7 @@ pub async fn get_tx_with_cells(
.trim_end_matches(';')
.to_string();

let mut query_builder = SqlBuilder::select_from(&format!("{} AS res", sql));
let mut query_builder = SqlBuilder::select_from(format!("{} AS res", sql));
query_builder
.field("tx_id")
.field("block_number")
Expand Down
8 changes: 4 additions & 4 deletions util/rich-indexer/src/tests/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async fn get_cells() {
search_key,
IndexerOrder::Asc,
100u32.into(),
Some(vec![5u8, 0, 0, 0, 0, 0, 0, 0].pack().into()),
Some([5u8, 0, 0, 0, 0, 0, 0, 0].pack().into()),
)
.await
.unwrap();
Expand Down Expand Up @@ -153,7 +153,7 @@ async fn get_cells() {
search_key,
IndexerOrder::Asc,
10u32.into(),
Some(vec![1u8, 0, 0, 0, 0, 0, 0, 0].pack().into()),
Some([1u8, 0, 0, 0, 0, 0, 0, 0].pack().into()),
)
.await
.unwrap();
Expand Down Expand Up @@ -198,7 +198,7 @@ async fn get_cells_filter_data() {
search_key,
IndexerOrder::Asc,
100u32.into(),
Some(vec![2u8, 0, 0, 0, 0, 0, 0, 0].pack().into()),
Some([2u8, 0, 0, 0, 0, 0, 0, 0].pack().into()),
)
.await
.unwrap();
Expand Down Expand Up @@ -245,7 +245,7 @@ async fn get_cells_by_cursor() {
search_key,
IndexerOrder::Asc,
3u32.into(),
Some(vec![0u8, 0, 0, 0, 0, 0, 0, 0].pack().into()),
Some([0u8, 0, 0, 0, 0, 0, 0, 0].pack().into()),
)
.await
.unwrap();
Expand Down

0 comments on commit 5dd4901

Please sign in to comment.