pub fn query_get_finished_amount(
    storage: &dyn Storage,
    sender_addr: String,
    block_time: u64,
) -> StdResult<Uint128> {
    let vec = to_vec(&sender_addr)?;
    let mut withdrawable_amount: Uint128 = Uint128::zero();
    let res: ReadonlyBucket<Uint128> =
        ReadonlyBucket::multilevel(storage, &[PREFIX_WAIT_MAP, &vec]);
    let _un: Vec<_> = res
        .range(None, None, Order::Ascending)
        .map(|item| {
            let (k, v) = item.unwrap();
            let user_batch: u64 = from_slice(&k).unwrap();
            let history = read_unbond_history(storage, user_batch);
            if let Ok(h) = history {
                if h.time < block_time {
                    withdrawable_amount += v * h.withdraw_rate;
                }
            }
        })
        .collect();
    Ok(withdrawable_amount)
}
/// Return the finished amount for all batches that has been before the given block time.
Return the finished amount for all batches that has been before the given block time.
Return the finished amount for all batches that has been before the given block time .
pub fn query_get_finished_amount(
    storage: &dyn Storage,
    sender_addr: String,
    block_time: u64,
) -> StdResult<Uint128> {
    let vec = to_vec(&sender_addr)?;
    let mut withdrawable_amount: Uint128 = Uint128::zero();
    let res: ReadonlyBucket<Uint128> =
        ReadonlyBucket::multilevel(storage, &[PREFIX_WAIT_MAP, &vec]);
    let _un: Vec<_> = res
        .range(None, None, Order::Ascending)
        .map(|item| {
            let (k, v) = item.unwrap();
            let user_batch: u64 = from_slice(&k).unwrap();
            let history = read_unbond_history(storage, user_batch);
            if let Ok(h) = history {
                if h.time < block_time {
                    withdrawable_amount += v * h.withdraw_rate;
                }
            }
        })
        .collect();
    Ok(withdrawable_amount)
}
pub fn query_get_finished_amount ( storage : & dyn Storage , sender_addr : String , block_time : u64 , ) -> StdResult < Uint128 > { let vec = to_vec ( & sender_addr ) ? ; let mut withdrawable_amount : Uint128 = Uint128 :: zero ( ) ; let res : ReadonlyBucket < Uint128 > = ReadonlyBucket :: multilevel ( storage , & [ PREFIX_WAIT_MAP , & vec ] ) ; let _un : Vec < _ > = res . range ( None , None , Order :: Ascending ) . map ( | item | { let ( k , v ) = item . unwrap ( ) ; let user_batch : u64 = from_slice ( & k ) . unwrap ( ) ; let history = read_unbond_history ( storage , user_batch ) ; if let Ok ( h ) = history { if h . time < block_time { withdrawable_amount += v * h . withdraw_rate ; } } } ) . collect ( ) ; Ok ( withdrawable_amount ) }
Return the finished amount for all batches that has been before the given block time.
Return the finished amount for all batches that has been before the given block time .
storage
&dyn Storage
sender_addr
String
block_time
u64
storage
&dyn Storage
sender_addr
String
block_time
u64