Skip to content

Commit 2731427

Browse files
committed
rpc: set_scripts do not realy need thread::spawn
1 parent c9d489d commit 2731427

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

light-client-bin/src/rpc.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,12 @@ impl BlockFilterRpc for BlockFilterRpcImpl {
135135
scripts: Vec<ScriptStatus>,
136136
command: Option<SetScriptsCommand>,
137137
) -> Result<()> {
138-
let (tx, rx) = std::sync::mpsc::channel();
139-
let swc = self.swc.clone();
140-
std::thread::spawn(move || {
141-
let mut matched_blocks = swc.matched_blocks().blocking_write();
142-
let scripts = scripts.into_iter().map(Into::into).collect();
143-
swc.storage()
144-
.update_filter_scripts(scripts, command.map(Into::into).unwrap_or_default());
145-
matched_blocks.clear();
146-
tx.send(()).unwrap();
147-
});
148-
rx.recv().unwrap();
138+
let mut matched_blocks = self.swc.matched_blocks().blocking_write();
139+
let scripts = scripts.into_iter().map(Into::into).collect();
140+
self.swc
141+
.storage()
142+
.update_filter_scripts(scripts, command.map(Into::into).unwrap_or_default());
143+
matched_blocks.clear();
149144
Ok(())
150145
}
151146

0 commit comments

Comments
 (0)