From d0bd17c5602746ff7bb3216c40ef989885a220e1 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 26 Oct 2023 13:14:43 +0100 Subject: [PATCH] use BufWritter to save the cache --- consensus/src/rpc/cache.rs | 5 ++++- consensus/src/rpc/discover.rs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/consensus/src/rpc/cache.rs b/consensus/src/rpc/cache.rs index f50aa4d6..2856f6c6 100644 --- a/consensus/src/rpc/cache.rs +++ b/consensus/src/rpc/cache.rs @@ -1,7 +1,9 @@ +use std::io::Write; use std::{ collections::HashMap, collections::HashSet, fmt::{Display, Formatter}, + io::BufWriter, path::Path, sync::Arc, }; @@ -35,8 +37,9 @@ impl ScanningCache { .truncate(true) .create(true) .open(file)?; - let mut writer = file.make_writer(); + let mut writer = BufWriter::new(file.make_writer()); bincode::encode_into_std_write(self, &mut writer, bincode::config::standard())?; + writer.flush()?; Ok(()) } diff --git a/consensus/src/rpc/discover.rs b/consensus/src/rpc/discover.rs index 4841bc0e..5dbda69b 100644 --- a/consensus/src/rpc/discover.rs +++ b/consensus/src/rpc/discover.rs @@ -7,7 +7,7 @@ use std::{ use futures::{ channel::mpsc::{self, SendError}, stream::FuturesUnordered, - SinkExt, + SinkExt, StreamExt, }; use monero_serai::rpc::HttpRpc; use tokio::time::timeout;