fn write(stakes: &Stakes) {
        // Encode the stakes as a set of uref names.
        let mut new_urefs: BTreeSet<String> = stakes
            .0
            .iter()
            .map(|(pub_key, balance)| {
                let key_bytes = pub_key.value();
                let mut hex_key = String::with_capacity(64);
                for byte in &key_bytes[..32] {
                    write!(hex_key, "{:02x}", byte).expect("Writing to a string cannot fail");
                }
                let mut uref = String::new();
                uref.write_fmt(format_args!("v_{}_{}", hex_key, balance))
                    .expect("Writing to a string cannot fail");
                uref
            })
            .collect();
        // Remove and add urefs to update the contract's known urefs accordingly.
        for (name, _) in contract_api::list_known_urefs() {
            if name.starts_with("v_") && !new_urefs.remove(&name) {
                contract_api::remove_uref(&name);
            }
        }
        for name in new_urefs {
            contract_api::add_uref(&name, &Key::Hash([0; 32]));
        }
    }
/// Writes the current stakes to the contract's known urefs.
Writes the current stakes to the contract's known urefs.
Writes the current stakes to the contract ' s known urefs .
fn write(stakes: &Stakes) {
        // Encode the stakes as a set of uref names.
        let mut new_urefs: BTreeSet<String> = stakes
            .0
            .iter()
            .map(|(pub_key, balance)| {
                let key_bytes = pub_key.value();
                let mut hex_key = String::with_capacity(64);
                for byte in &key_bytes[..32] {
                    write!(hex_key, "{:02x}", byte).expect("Writing to a string cannot fail");
                }
                let mut uref = String::new();
                uref.write_fmt(format_args!("v_{}_{}", hex_key, balance))
                    .expect("Writing to a string cannot fail");
                uref
            })
            .collect();
        // Remove and add urefs to update the contract's known urefs accordingly.
        for (name, _) in contract_api::list_known_urefs() {
            if name.starts_with("v_") && !new_urefs.remove(&name) {
                contract_api::remove_uref(&name);
            }
        }
        for name in new_urefs {
            contract_api::add_uref(&name, &Key::Hash([0; 32]));
        }
    }
fn write ( stakes : & Stakes ) { // Encode the stakes as a set of uref names. let mut new_urefs : BTreeSet < String > = stakes . 0 . iter ( ) . map ( | ( pub_key , balance ) | { let key_bytes = pub_key . value ( ) ; let mut hex_key = String :: with_capacity ( 64 ) ; for byte in & key_bytes [ .. 32 ] { write ! ( hex_key " " byte ) . expect ( " " ) ; } let mut uref = String :: new ( ) ; uref . write_fmt ( format_args ! ( " " hex_key balance ) ) . expect ( " " ) ; uref } ) . collect ( ) ; // Remove and add urefs to update the contract's known urefs accordingly. for ( name , _ ) in contract_api :: list_known_urefs ( ) { if name . starts_with ( " " ) && ! new_urefs . remove ( & name ) { contract_api :: remove_uref ( & name ) ; } } for name in new_urefs { contract_api :: add_uref ( & name , & Key :: Hash ( [ 0 ; 32 ] ) ) ; } }
Writes the current stakes to the contract's known urefs.
Writes the current stakes to the contract ' s known urefs .
stakes
&Stakes
stakes
&Stakes