fn delete_replica(who: &<T as system::Config>::AccountId, cid: &MerkleRoot, anchor: &TarsAnchor) -> u64 {
        // 1. Delete replica from file_info
        if let Some((mut file_info, used_info)) = <Files<T>>::get(cid) {
            let mut is_to_decreased = false;
            file_info.replicas.retain(|replica| {
                if replica.who == *who && replica.is_reported {
                    // if this anchor didn't report work, we already decrease the `reported_replica_count` in `do_calculate_reward`
                    is_to_decreased = true;
                }
                replica.who != *who
            });
            if is_to_decreased {
                file_info.reported_replica_count = file_info.reported_replica_count.saturating_sub(1);
            }
            <Files<T>>::insert(cid, (file_info, used_info));
        }

        // 2. Delete anchor from file_info/file_trash and return whether it is counted
        Self::delete_used_group(cid, anchor)
    }
/// Node who delete the replica
/// Accept id(who, anchor), cid and current block number
/// Returns the real used size of this file
Node who delete the replica
Accept id(who, anchor), cid and current block number
Returns the real used size of this file
Node who delete the replica Accept id ( who anchor ) cid and current block number Returns the real used size of this file
fn delete_replica(who: &<T as system::Config>::AccountId, cid: &MerkleRoot, anchor: &TarsAnchor) -> u64 {
        // 1. Delete replica from file_info
        if let Some((mut file_info, used_info)) = <Files<T>>::get(cid) {
            let mut is_to_decreased = false;
            file_info.replicas.retain(|replica| {
                if replica.who == *who && replica.is_reported {
                    // if this anchor didn't report work, we already decrease the `reported_replica_count` in `do_calculate_reward`
                    is_to_decreased = true;
                }
                replica.who != *who
            });
            if is_to_decreased {
                file_info.reported_replica_count = file_info.reported_replica_count.saturating_sub(1);
            }
            <Files<T>>::insert(cid, (file_info, used_info));
        }
        // 2. Delete anchor from file_info/file_trash and return whether it is counted
        Self::delete_used_group(cid, anchor)
    }
fn delete_replica ( who : & < T as system :: Config > :: AccountId , cid : & MerkleRoot , anchor : & TarsAnchor ) -> u64 { // 1. Delete replica from file_info if let Some ( ( mut file_info , used_info ) ) = < Files < T > > :: get ( cid ) { let mut is_to_decreased = false ; file_info . replicas . retain ( | replica | { if replica . who == * who && replica . is_reported { // if this anchor didn't report work, we already decrease the `reported_replica_count` in `do_calculate_reward` is_to_decreased = true ; } replica . who != * who } ) ; if is_to_decreased { file_info . reported_replica_count = file_info . reported_replica_count . saturating_sub ( 1 ) ; } < Files < T > > :: insert ( cid , ( file_info , used_info ) ) ; } // 2. Delete anchor from file_info/file_trash and return whether it is counted Self :: delete_used_group ( cid , anchor ) }
Node who delete the replica
Accept id(who, anchor), cid and current block number
Returns the real used size of this file
Node who delete the replica Accept id ( who anchor ) cid and current block number Returns the real used size of this file
who
&<T as system::Config>::AccountId
cid
&MerkleRoot
anchor
&TarsAnchor