use BufWritter to save the cache

This commit is contained in:
Boog900 2023-10-26 13:14:43 +01:00
parent 65378b0523
commit d0bd17c560
No known key found for this signature in database
GPG key ID: 5401367FB7302004
2 changed files with 5 additions and 2 deletions

View file

@ -1,7 +1,9 @@
use std::io::Write;
use std::{ use std::{
collections::HashMap, collections::HashMap,
collections::HashSet, collections::HashSet,
fmt::{Display, Formatter}, fmt::{Display, Formatter},
io::BufWriter,
path::Path, path::Path,
sync::Arc, sync::Arc,
}; };
@ -35,8 +37,9 @@ impl ScanningCache {
.truncate(true) .truncate(true)
.create(true) .create(true)
.open(file)?; .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())?; bincode::encode_into_std_write(self, &mut writer, bincode::config::standard())?;
writer.flush()?;
Ok(()) Ok(())
} }

View file

@ -7,7 +7,7 @@ use std::{
use futures::{ use futures::{
channel::mpsc::{self, SendError}, channel::mpsc::{self, SendError},
stream::FuturesUnordered, stream::FuturesUnordered,
SinkExt, SinkExt, StreamExt,
}; };
use monero_serai::rpc::HttpRpc; use monero_serai::rpc::HttpRpc;
use tokio::time::timeout; use tokio::time::timeout;