From f99e0be7bb2dc89bdc96a3df7141e3154a1ae102 Mon Sep 17 00:00:00 2001 From: driftluo Date: Tue, 19 Nov 2024 11:09:24 +0800 Subject: [PATCH] chore: impl review suggestion --- resource/src/lib.rs | 4 +--- tx-pool/src/block_assembler/mod.rs | 2 +- util/jsonrpc-types/src/blockchain.rs | 2 +- .../src/indexer_handle/async_indexer_handle/get_cells.rs | 2 +- .../async_indexer_handle/get_cells_capacity.rs | 2 +- .../async_indexer_handle/get_transactions.rs | 8 ++++---- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/resource/src/lib.rs b/resource/src/lib.rs index b69b644b0f..924d98c15b 100644 --- a/resource/src/lib.rs +++ b/resource/src/lib.rs @@ -208,9 +208,7 @@ impl Resource { SourceFiles::new(&BUNDLED_CELL, &BUNDLED).read(bundled) } Resource::FileSystem { file } => Ok(Box::new(BufReader::new(fs::File::open(file)?))), - Resource::Raw { raw } => Ok(Box::new(BufReader::new(Cursor::new( - raw.to_owned().into_bytes(), - )))), + Resource::Raw { raw } => Ok(Box::new(Cursor::new(raw.to_owned().into_bytes()))), } } diff --git a/tx-pool/src/block_assembler/mod.rs b/tx-pool/src/block_assembler/mod.rs index 78949e6ba5..dc6e0a1e93 100644 --- a/tx-pool/src/block_assembler/mod.rs +++ b/tx-pool/src/block_assembler/mod.rs @@ -463,7 +463,7 @@ impl BlockAssembler { config: &BlockAssemblerConfig, snapshot: &Snapshot, ) -> CellbaseWitness { - let hash_type: ScriptHashType = config.hash_type.into(); + let hash_type: ScriptHashType = config.hash_type.clone().into(); let cellbase_lock = Script::new_builder() .args(config.args.as_bytes().pack()) .code_hash(config.code_hash.pack()) diff --git a/util/jsonrpc-types/src/blockchain.rs b/util/jsonrpc-types/src/blockchain.rs index abdf5ce939..e5812d1d9e 100644 --- a/util/jsonrpc-types/src/blockchain.rs +++ b/util/jsonrpc-types/src/blockchain.rs @@ -25,7 +25,7 @@ use std::fmt; /// when the low 1 bit is 0, it indicates the data, /// and then it relies on the high 7 bits to indicate /// that the data actually corresponds to the version. -#[derive(Default, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, JsonSchema)] +#[derive(Default, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum ScriptHashType { /// Type "data" matches script code via cell data hash, and run the script code in v0 CKB VM. diff --git a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells.rs b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells.rs index 524abbebd1..ae17b25c56 100644 --- a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells.rs +++ b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells.rs @@ -190,7 +190,7 @@ impl AsyncRichIndexerHandle { if let Some(script) = filter.script.as_ref() { query = query .bind(script.code_hash.as_bytes()) - .bind(script.hash_type as i16); + .bind(script.hash_type.clone() as i16); // Default prefix search query = query .bind(script.args.as_bytes()) diff --git a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells_capacity.rs b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells_capacity.rs index 808336c074..9b72ffff7c 100644 --- a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells_capacity.rs +++ b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells_capacity.rs @@ -144,7 +144,7 @@ impl AsyncRichIndexerHandle { if let Some(script) = filter.script.as_ref() { query = query .bind(script.code_hash.as_bytes()) - .bind(script.hash_type as i16); + .bind(script.hash_type.clone() as i16); // Default prefix search query = query .bind(script.args.as_bytes()) diff --git a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs index 342c1c1ef8..7b9b425455 100644 --- a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs +++ b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs @@ -193,7 +193,7 @@ pub async fn get_tx_with_cell( for _ in 0..2 { query = query .bind(search_key.script.code_hash.as_bytes()) - .bind(search_key.script.hash_type as i16); + .bind(search_key.script.hash_type.clone() as i16); match &search_key.script_search_mode { Some(IndexerSearchMode::Prefix) | None => { query = query @@ -217,7 +217,7 @@ pub async fn get_tx_with_cell( if let Some(script) = filter.script.as_ref() { query = query .bind(script.code_hash.as_bytes()) - .bind(script.hash_type as i16); + .bind(script.hash_type.clone() as i16); // Default prefix search query = query .bind(script.args.as_bytes()) @@ -343,7 +343,7 @@ pub async fn get_tx_with_cells( for _ in 0..2 { query = query .bind(search_key.script.code_hash.as_bytes()) - .bind(search_key.script.hash_type as i16); + .bind(search_key.script.hash_type.clone() as i16); match &search_key.script_search_mode { Some(IndexerSearchMode::Prefix) | None => { query = query @@ -367,7 +367,7 @@ pub async fn get_tx_with_cells( if let Some(script) = filter.script.as_ref() { query = query .bind(script.code_hash.as_bytes()) - .bind(script.hash_type as i16); + .bind(script.hash_type.clone() as i16); // Default prefix search query = query .bind(script.args.as_bytes())