mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-01-30 18:42:15 +00:00
Buffered read/write
This commit is contained in:
parent
8ff6d15e32
commit
4dbba14f4e
@ -4,6 +4,7 @@ use std::path::Path;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
use std::io::{BufReader, BufWriter};
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
|
||||
@ -72,7 +73,7 @@ impl LightClient {
|
||||
print!("Reading wallet...");
|
||||
io::stdout().flush().ok().expect("Could not flush stdout");
|
||||
let mut file_buffer = match File::open("wallet.dat") {
|
||||
Ok(f) => f,
|
||||
Ok(f) => BufReader::new(f),
|
||||
Err(e) => {
|
||||
println!("[Error: {}]", e.description());
|
||||
return;
|
||||
@ -87,7 +88,9 @@ impl LightClient {
|
||||
pub fn do_save(&self) {
|
||||
print!("Saving wallet...");
|
||||
io::stdout().flush().ok().expect("Could not flush stdout");
|
||||
let mut file_buffer = File::create("wallet.dat").unwrap();
|
||||
let mut file_buffer = BufWriter::with_capacity(
|
||||
1_000_000, // 1 MB write buffer
|
||||
File::create("wallet.dat").unwrap());
|
||||
|
||||
self.wallet.write(&mut file_buffer).unwrap();
|
||||
println!("[OK]");
|
||||
|
Loading…
Reference in New Issue
Block a user