Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Use BufReader and BufWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka committed Sep 7, 2018
1 parent 2f593df commit 1b05442
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions substrate/network-libp2p/src/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use parking_lot::Mutex;
use libp2p::{Multiaddr, PeerId};
use serde_json;
use std::{cmp, fs};
use std::io::{Read, Cursor, Error as IoError, ErrorKind as IoErrorKind, Write};
use std::io::{Read, Cursor, Error as IoError, ErrorKind as IoErrorKind, Write, BufReader, BufWriter};
use std::path::{Path, PathBuf};
use std::time::{Duration, Instant, SystemTime};

Expand Down Expand Up @@ -101,7 +101,7 @@ impl NetTopology {
};

let file = fs::File::create(path)?;
serialize(file, &self.store)
serialize(BufWriter::with_capacity(1024 * 1024, file), &self.store)
}

/// Perform a cleanup pass, removing all obsolete addresses and peers.
Expand Down Expand Up @@ -513,7 +513,7 @@ fn try_load(path: impl AsRef<Path>) -> FnvHashMap<PeerId, PeerInfo> {

let mut first_byte = [0];
let num_read = match file.read(&mut first_byte) {
Ok(f) => f,
Ok(f) => BufReader::with_capacity(1024 * 1024, f),
Err(err) => {
// TODO: DRY
warn!(target: "sub-libp2p", "Failed to read peer storage file: {:?}", err);
Expand Down

0 comments on commit 1b05442

Please sign in to comment.