Skip to content

Commit

Permalink
fix bug for filter scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Officeyutong committed Dec 12, 2024
1 parent 708b6c2 commit deb3ce7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions light-client-lib/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use crate::storage;

#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen)]
#[derive(Deserialize, Serialize, Eq, PartialEq)]
#[derive(Deserialize, Serialize, Eq, PartialEq, Debug)]
#[serde(rename_all = "snake_case")]
pub enum SetScriptsCommand {
// Replace all scripts with new scripts, non-exist scripts will be deleted
Expand Down Expand Up @@ -39,7 +39,7 @@ pub enum FetchStatus<T> {
NotFound,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Debug)]
pub struct ScriptStatus {
pub script: Script,
pub script_type: ScriptType,
Expand Down
5 changes: 3 additions & 2 deletions light-client-lib/src/storage/db/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{
collections::{HashMap, HashSet},
path::Path,
sync::atomic::AtomicBool,
usize,
};

use super::super::{
Expand Down Expand Up @@ -367,11 +368,11 @@ impl Storage {
start_key_bound: key_prefix_clone.clone(),
order: CursorDirection::NextUnique,
take_while: Box::new(move |raw_key: &[u8]| raw_key.starts_with(&key_prefix_clone)),
limit: 1,
limit: usize::MAX,
skip: 0,
})
.unwrap();

debug!("raw get filter script response: {:#?}", value);
if let DbCommandResponse::Iterator { kvs } = value {
kvs.into_iter()
.map(|kv| (kv.key, kv.value))
Expand Down
4 changes: 2 additions & 2 deletions light-client-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use ckb_light_client_lib::{
types::RunEnv,
verify::verify_tx,
};
use log::debug;
use log::{debug, info};
use serde::{Deserialize, Serialize};
use serde_wasm_bindgen::Serializer;
use wasm_bindgen::prelude::*;
Expand Down Expand Up @@ -477,7 +477,7 @@ pub fn set_scripts(
.into_iter()
.map(serde_wasm_bindgen::from_value::<ScriptStatus>)
.collect::<Result<Vec<_>, _>>()?;

debug!("Update scripts, {:?}, {:?}", scripts, command);
STORAGE_WITH_DATA
.get()
.unwrap()
Expand Down

0 comments on commit deb3ce7

Please sign in to comment.