pub fn read<R: Read + Seek>(mut reader: R) -> std::io::Result<BlockChain> {
        reader.seek(SeekFrom::Start(8))?;
        let mut blocks = vec![];
        let mut block_amount = [0; 8];
        reader.read_exact(&mut block_amount)?;
        let block_amount = u8_array_to_u64(&block_amount);
        for _ in 0..block_amount {
            blocks.push(Block::read(reader.by_ref())?);
        }
        let tree_cred =
            MerkleTree::read(reader.by_ref(), TreeType::Credential, CREDENTIAL_MT_DEPTH)?;
        let tree_note = MerkleTree::read(reader.by_ref(), TreeType::Note, NOTE_MT_DEPTH)?;
        let tree_mem = MerkleTree::read(reader.by_ref(), TreeType::Memory, MEMORY_MT_DEPTH)?;
        let new_block = Some(Block::new(blocks.last().unwrap()));
        Ok(BlockChain {
            blocks,
            tree_cred,
            tree_note,
            tree_mem,
            new_block,
        })
    }
/// Read a `Blockchain` file from a `reader` and return the created object.
Read a `Blockchain` file from a `reader` and return the created object.
Read a ` Blockchain ` file from a ` reader ` and return the created object .
pub fn read<R: Read + Seek>(mut reader: R) -> std::io::Result<BlockChain> {
        reader.seek(SeekFrom::Start(8))?;
        let mut blocks = vec![];
        let mut block_amount = [0; 8];
        reader.read_exact(&mut block_amount)?;
        let block_amount = u8_array_to_u64(&block_amount);
        for _ in 0..block_amount {
            blocks.push(Block::read(reader.by_ref())?);
        }
        let tree_cred =
            MerkleTree::read(reader.by_ref(), TreeType::Credential, CREDENTIAL_MT_DEPTH)?;
        let tree_note = MerkleTree::read(reader.by_ref(), TreeType::Note, NOTE_MT_DEPTH)?;
        let tree_mem = MerkleTree::read(reader.by_ref(), TreeType::Memory, MEMORY_MT_DEPTH)?;
        let new_block = Some(Block::new(blocks.last().unwrap()));
        Ok(BlockChain {
            blocks,
            tree_cred,
            tree_note,
            tree_mem,
            new_block,
        })
    }
pub fn read < R : Read + Seek > ( mut reader : R ) -> std :: io :: Result < BlockChain > { reader . seek ( SeekFrom :: Start ( 8 ) ) ? ; let mut blocks = vec ! [ ] ; let mut block_amount = [ 0 ; 8 ] ; reader . read_exact ( & mut block_amount ) ? ; let block_amount = u8_array_to_u64 ( & block_amount ) ; for _ in 0 .. block_amount { blocks . push ( Block :: read ( reader . by_ref ( ) ) ? ) ; } let tree_cred = MerkleTree :: read ( reader . by_ref ( ) , TreeType :: Credential , CREDENTIAL_MT_DEPTH ) ? ; let tree_note = MerkleTree :: read ( reader . by_ref ( ) , TreeType :: Note , NOTE_MT_DEPTH ) ? ; let tree_mem = MerkleTree :: read ( reader . by_ref ( ) , TreeType :: Memory , MEMORY_MT_DEPTH ) ? ; let new_block = Some ( Block :: new ( blocks . last ( ) . unwrap ( ) ) ) ; Ok ( BlockChain { blocks , tree_cred , tree_note , tree_mem , new_block , } ) }
Read a `Blockchain` file from a `reader` and return the created object.
Read a ` Blockchain ` file from a ` reader ` and return the created object .
reader
R
reader
R