Browse Source

undo gzip

checkpoints
DenioD 4 years ago
parent
commit
32ca60735b
  1. 4
      lib/src/lightclient.rs
  2. 15
      lib/src/lightwallet.rs

4
lib/src/lightclient.rs

@ -426,8 +426,8 @@ impl LightClient {
let version = inp.read_u64::<LittleEndian>().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<dyn Read> = if version <= 4 {
// At version 5, we're writing the rest of the file as a compressed stream (gzip)
let mut reader: Box<dyn Read> = if version != 5 {
Box::new(inp)
} else {
Box::new(Decoder::new(inp).unwrap())

15
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<dyn Read> = if version <= 4 {
// At version 5, we're writing the rest of the file as a compressed stream (gzip)
let mut reader: Box<dyn Read> = if version !=5 {
info!("Reading direct");
Box::new(inp)
} else {
@ -342,17 +342,14 @@ impl LightWallet {
})
}
pub fn write<W: Write>(&self, mut out: W) -> io::Result<()> {
pub fn write<W: 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::<LittleEndian>(LightWallet::serialized_version())?;
// Gzip encoder
let mut writer = AutoFinishUnchecked::new(Encoder::new(out).unwrap());
writer.write_u64::<LittleEndian>(LightWallet::serialized_version())?;
// Write if it is locked
writer.write_u8(if self.encrypted {1} else {0})?;

Loading…
Cancel
Save