fn files_transition_check(
        prev_pk: &TarsPubKey,
        new_files_size: u64,
        reported_added_files: &Vec<(MerkleRoot, u64, u64)>,
        reported_deleted_files: &Vec<(MerkleRoot, u64, u64)>,
        reported_files_root: &MerkleRoot
    ) -> bool {
        if let Some(prev_wr) = Self::work_reports(&Self::pub_keys(&prev_pk).anchor.unwrap_or_default()) {
            let old_files_size = prev_wr.reported_files_size;
            let added_files_size = reported_added_files.iter().fold(0, |acc, (_, size, _)| acc+*size);
            let deleted_files_size = reported_deleted_files.iter().fold(0, |acc, (_, size, _)| acc+*size);
            // File size change should equal between before and after
            return if added_files_size == 0 && deleted_files_size == 0 {
                reported_files_root == &prev_wr.reported_files_root
            } else {
                old_files_size.saturating_add(added_files_size).saturating_sub(deleted_files_size) == new_files_size
            }
        }
        // Or just return for the baby 👶🏼
        true
    }
// PRIVATE IMMUTABLES
/// This function will check work report files status transition
PRIVATE IMMUTABLES
This function will check work report files status transition
PRIVATE IMMUTABLES This function will check work report files status transition
fn files_transition_check(
        prev_pk: &TarsPubKey,
        new_files_size: u64,
        reported_added_files: &Vec<(MerkleRoot, u64, u64)>,
        reported_deleted_files: &Vec<(MerkleRoot, u64, u64)>,
        reported_files_root: &MerkleRoot
    ) -> bool {
        if let Some(prev_wr) = Self::work_reports(&Self::pub_keys(&prev_pk).anchor.unwrap_or_default()) {
            let old_files_size = prev_wr.reported_files_size;
            let added_files_size = reported_added_files.iter().fold(0, |acc, (_, size, _)| acc+*size);
            let deleted_files_size = reported_deleted_files.iter().fold(0, |acc, (_, size, _)| acc+*size);
            // File size change should equal between before and after
            return if added_files_size == 0 && deleted_files_size == 0 {
                reported_files_root == &prev_wr.reported_files_root
            } else {
                old_files_size.saturating_add(added_files_size).saturating_sub(deleted_files_size) == new_files_size
            }
        }
        // Or just return for the baby 👶🏼
        true
    }
fn files_transition_check ( prev_pk : & TarsPubKey , new_files_size : u64 , reported_added_files : & Vec < ( MerkleRoot , u64 , u64 ) > , reported_deleted_files : & Vec < ( MerkleRoot , u64 , u64 ) > , reported_files_root : & MerkleRoot ) -> bool { if let Some ( prev_wr ) = Self :: work_reports ( & Self :: pub_keys ( & prev_pk ) . anchor . unwrap_or_default ( ) ) { let old_files_size = prev_wr . reported_files_size ; let added_files_size = reported_added_files . iter ( ) . fold ( 0 , | acc , ( _ , size , _ ) | acc + * size ) ; let deleted_files_size = reported_deleted_files . iter ( ) . fold ( 0 , | acc , ( _ , size , _ ) | acc + * size ) ; // File size change should equal between before and after return if added_files_size == 0 && deleted_files_size == 0 { reported_files_root == & prev_wr . reported_files_root } else { old_files_size . saturating_add ( added_files_size ) . saturating_sub ( deleted_files_size ) == new_files_size } } // Or just return for the baby 👶🏼 true }
PRIVATE IMMUTABLES
This function will check work report files status transition
PRIVATE IMMUTABLES This function will check work report files status transition
prev_pk
&TarsPubKey
new_files_size
u64
reported_added_files
&Vec<(MerkleRoot, u64, u64)>
reported_deleted_files
&Vec<(MerkleRoot, u64, u64)>
reported_files_root
&MerkleRoot