pub fn store_depositor_stats(
    storage: &mut dyn Storage,
    depositor: &Addr,
    depositor_stats: DepositorStatsInfo,
    height: u64,
) -> StdResult<()> {
    let update_stats = |maybe_stats: Option<DepositorStatsInfo>| -> StdResult<DepositorStatsInfo> {
        let stats = maybe_stats.unwrap_or(DepositorStatsInfo {
            shares: Uint256::zero(),
            num_tickets: 0,
            operator_addr: Addr::unchecked(""),
        });
        if stats.num_tickets != depositor_stats.num_tickets {
            return Err(StdError::generic_err(
                "Can't change num tickets and save depositor stats",
            ));
        }
        Ok(depositor_stats)
    };

    DEPOSITOR_STATS.update(storage, depositor, height, update_stats)?;

    Ok(())
}
/// Store depositor stats
/// Does *not* store changes to num_tickets
/// in order to ensure that num_tickets always stays in sync with DepositorData
Store depositor stats
Does *not* store changes to num_tickets
in order to ensure that num_tickets always stays in sync with DepositorData
Store depositor stats Does * not * store changes to num_tickets in order to ensure that num_tickets always stays in sync with DepositorData
pub fn store_depositor_stats(
    storage: &mut dyn Storage,
    depositor: &Addr,
    depositor_stats: DepositorStatsInfo,
    height: u64,
) -> StdResult<()> {
    let update_stats = |maybe_stats: Option<DepositorStatsInfo>| -> StdResult<DepositorStatsInfo> {
        let stats = maybe_stats.unwrap_or(DepositorStatsInfo {
            shares: Uint256::zero(),
            num_tickets: 0,
            operator_addr: Addr::unchecked(""),
        });
        if stats.num_tickets != depositor_stats.num_tickets {
            return Err(StdError::generic_err(
                "Can't change num tickets and save depositor stats",
            ));
        }
        Ok(depositor_stats)
    };
    DEPOSITOR_STATS.update(storage, depositor, height, update_stats)?;
    Ok(())
}
pub fn store_depositor_stats ( storage : & mut dyn Storage , depositor : & Addr , depositor_stats : DepositorStatsInfo , height : u64 , ) -> StdResult < ( ) > { let update_stats = | maybe_stats : Option < DepositorStatsInfo > | -> StdResult < DepositorStatsInfo > { let stats = maybe_stats . unwrap_or ( DepositorStatsInfo { shares : Uint256 :: zero ( ) , num_tickets : 0 , operator_addr : Addr :: unchecked ( " " ) , } ) ; if stats . num_tickets != depositor_stats . num_tickets { return Err ( StdError :: generic_err ( " " , ) ) ; } Ok ( depositor_stats ) } ; DEPOSITOR_STATS . update ( storage , depositor , height , update_stats ) ? ; Ok ( ( ) ) }
Store depositor stats
Does *not* store changes to num_tickets
in order to ensure that num_tickets always stays in sync with DepositorData
Store depositor stats Does * not * store changes to num_tickets in order to ensure that num_tickets always stays in sync with DepositorData
storage
&mut dyn Storage
depositor
&Addr
depositor_stats
DepositorStatsInfo
height
u64
storage
&mut dyn Storage
depositor
&Addr
depositor_stats
DepositorStatsInfo
height
u64