From 32ca60735b3529ff8589ab08fc16678f508a9359 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sat, 16 May 2020 17:11:11 +0200 Subject: [PATCH] undo gzip --- lib/src/lightclient.rs | 4 ++-- lib/src/lightwallet.rs | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/src/lightclient.rs b/lib/src/lightclient.rs index 83a8728..157c318 100644 --- a/lib/src/lightclient.rs +++ b/lib/src/lightclient.rs @@ -426,8 +426,8 @@ impl LightClient { let version = inp.read_u64::().unwrap(); println!("Reading wallet version {}", version); - // After version 5, we're writing the rest of the file as a compressed stream (gzip) - let mut reader: Box = if version <= 4 { + // At version 5, we're writing the rest of the file as a compressed stream (gzip) + let mut reader: Box = if version != 5 { Box::new(inp) } else { Box::new(Decoder::new(inp).unwrap()) diff --git a/lib/src/lightwallet.rs b/lib/src/lightwallet.rs index cfd93b3..6e56ca0 100644 --- a/lib/src/lightwallet.rs +++ b/lib/src/lightwallet.rs @@ -11,7 +11,7 @@ use log::{info, warn, error}; use protobuf::parse_from_bytes; -use libflate::{gzip::{Decoder, Encoder}, finish::AutoFinishUnchecked}; +use libflate::gzip::{Decoder}; use secp256k1::SecretKey; use bip39::{Mnemonic, Language}; @@ -135,7 +135,7 @@ pub struct LightWallet { impl LightWallet { pub fn serialized_version() -> u64 { - return 5; + return 6; } fn get_taddr_from_bip39seed(config: &LightClientConfig, bip39_seed: &[u8], pos: u32) -> SecretKey { @@ -243,8 +243,8 @@ impl LightWallet { println!("Reading wallet version {}", version); info!("Reading wallet version {}", version); - // After version 5, we're writing the rest of the file as a compressed stream (gzip) - let mut reader: Box = if version <= 4 { + // At version 5, we're writing the rest of the file as a compressed stream (gzip) + let mut reader: Box = if version !=5 { info!("Reading direct"); Box::new(inp) } else { @@ -342,17 +342,14 @@ impl LightWallet { }) } - pub fn write(&self, mut out: W) -> io::Result<()> { + pub fn write(&self, mut writer: W) -> io::Result<()> { if self.encrypted && self.unlocked { return Err(Error::new(ErrorKind::InvalidInput, format!("Cannot write while wallet is unlocked while encrypted."))); } // Write the version - out.write_u64::(LightWallet::serialized_version())?; - - // Gzip encoder - let mut writer = AutoFinishUnchecked::new(Encoder::new(out).unwrap()); + writer.write_u64::(LightWallet::serialized_version())?; // Write if it is locked writer.write_u8(if self.encrypted {1} else {0})?;