fn read() -> Result<Stakes> {
        let mut stakes = BTreeMap::new();
        for (name, _) in contract_api::list_known_urefs() {
            let mut split_name = name.split('_');
            if Some("v") != split_name.next() {
                continue;
            }
            let hex_key = split_name
                .next()
                .ok_or(Error::StakesKeyDeserializationFailed)?;
            let mut key_bytes = [0u8; 32];
            for i in 0..32 {
                key_bytes[i] = u8::from_str_radix(&hex_key[2 * i..2 * (i + 1)], 16)
                    .map_err(|_| Error::StakesKeyDeserializationFailed)?;
            }
            let pub_key = PublicKey::new(key_bytes);
            let balance = split_name
                .next()
                .and_then(|b| U512::from_dec_str(b).ok())
                .ok_or(Error::StakesDeserializationFailed)?;
            stakes.insert(pub_key, balance);
        }
        if stakes.is_empty() {
            return Err(Error::StakesNotFound);
        }
        Ok(Stakes(stakes))
    }
/// Reads the current stakes from the contract's known urefs.
Reads the current stakes from the contract's known urefs.
Reads the current stakes from the contract ' s known urefs .
fn read() -> Result<Stakes> {
        let mut stakes = BTreeMap::new();
        for (name, _) in contract_api::list_known_urefs() {
            let mut split_name = name.split('_');
            if Some("v") != split_name.next() {
                continue;
            }
            let hex_key = split_name
                .next()
                .ok_or(Error::StakesKeyDeserializationFailed)?;
            let mut key_bytes = [0u8; 32];
            for i in 0..32 {
                key_bytes[i] = u8::from_str_radix(&hex_key[2 * i..2 * (i + 1)], 16)
                    .map_err(|_| Error::StakesKeyDeserializationFailed)?;
            }
            let pub_key = PublicKey::new(key_bytes);
            let balance = split_name
                .next()
                .and_then(|b| U512::from_dec_str(b).ok())
                .ok_or(Error::StakesDeserializationFailed)?;
            stakes.insert(pub_key, balance);
        }
        if stakes.is_empty() {
            return Err(Error::StakesNotFound);
        }
        Ok(Stakes(stakes))
    }
fn read ( ) -> Result < Stakes > { let mut stakes = BTreeMap :: new ( ) ; for ( name , _ ) in contract_api :: list_known_urefs ( ) { let mut split_name = name . split ( '_' ) ; if Some ( " " ) != split_name . next ( ) { continue ; } let hex_key = split_name . next ( ) . ok_or ( Error :: StakesKeyDeserializationFailed ) ? ; let mut key_bytes = [ 0u8 ; 32 ] ; for i in 0 .. 32 { key_bytes [ i ] = u8 :: from_str_radix ( & hex_key [ 2 * i .. 2 * ( i + 1 ) ] , 16 ) . map_err ( | _ | Error :: StakesKeyDeserializationFailed ) ? ; } let pub_key = PublicKey :: new ( key_bytes ) ; let balance = split_name . next ( ) . and_then ( | b | U512 :: from_dec_str ( b ) . ok ( ) ) . ok_or ( Error :: StakesDeserializationFailed ) ? ; stakes . insert ( pub_key , balance ) ; } if stakes . is_empty ( ) { return Err ( Error :: StakesNotFound ) ; } Ok ( Stakes ( stakes ) ) }
Reads the current stakes from the contract's known urefs.
Reads the current stakes from the contract ' s known urefs .