2022-08-15 11:19:46 -07:00
|
|
|
//! Current cluster fees.
|
2019-05-30 15:18:48 -07:00
|
|
|
//!
|
2022-08-15 11:19:46 -07:00
|
|
|
//! The _fees sysvar_ provides access to the [`Fees`] type, which contains the
|
|
|
|
//! current [`FeeCalculator`].
|
|
|
|
//!
|
|
|
|
//! [`Fees`] implements [`Sysvar::get`] and can be loaded efficiently without
|
|
|
|
//! passing the sysvar account ID to the program.
|
|
|
|
//!
|
|
|
|
//! This sysvar is deprecated and will not be available in the future.
|
|
|
|
//! Transaction fees should be determined with the [`getFeeForMessage`] RPC
|
|
|
|
//! method. For additional context see the [Comprehensive Compute Fees
|
|
|
|
//! proposal][ccf].
|
|
|
|
//!
|
|
|
|
//! [`getFeeForMessage`]: https://docs.solana.com/developing/clients/jsonrpc-api#getfeeformessage
|
|
|
|
//! [ccf]: https://docs.solana.com/proposals/comprehensive-compute-fees
|
|
|
|
//!
|
|
|
|
//! See also the Solana [documentation on the fees sysvar][sdoc].
|
|
|
|
//!
|
|
|
|
//! [sdoc]: https://docs.solana.com/developing/runtime-facilities/sysvars#fees
|
|
|
|
|
2021-07-29 10:48:14 -07:00
|
|
|
#![allow(deprecated)]
|
|
|
|
|
2022-05-16 12:30:37 -07:00
|
|
|
use {
|
|
|
|
crate::{
|
2022-11-09 09:15:42 -08:00
|
|
|
fee_calculator::FeeCalculator, impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar,
|
2022-05-16 12:30:37 -07:00
|
|
|
},
|
2022-11-09 09:15:42 -08:00
|
|
|
solana_sdk_macro::CloneZeroed,
|
2021-04-12 16:04:57 -07:00
|
|
|
};
|
2019-05-30 15:18:48 -07:00
|
|
|
|
2021-07-29 10:48:14 -07:00
|
|
|
crate::declare_deprecated_sysvar_id!("SysvarFees111111111111111111111111111111111", Fees);
|
2019-05-30 15:18:48 -07:00
|
|
|
|
2022-08-15 11:19:46 -07:00
|
|
|
/// Transaction fees.
|
2021-07-29 10:48:14 -07:00
|
|
|
#[deprecated(
|
2021-10-26 09:06:41 -07:00
|
|
|
since = "1.9.0",
|
2021-07-29 10:48:14 -07:00
|
|
|
note = "Please do not use, will no longer be available in the future"
|
|
|
|
)]
|
2019-05-30 15:18:48 -07:00
|
|
|
#[repr(C)]
|
2022-11-09 09:15:42 -08:00
|
|
|
#[derive(Serialize, Deserialize, Debug, CloneZeroed, Default, PartialEq, Eq)]
|
2019-05-30 15:18:48 -07:00
|
|
|
pub struct Fees {
|
|
|
|
pub fee_calculator: FeeCalculator,
|
|
|
|
}
|
2022-05-16 12:30:37 -07:00
|
|
|
|
2020-10-28 22:01:07 -07:00
|
|
|
impl Fees {
|
|
|
|
pub fn new(fee_calculator: &FeeCalculator) -> Self {
|
2021-07-29 10:48:14 -07:00
|
|
|
#[allow(deprecated)]
|
2020-10-28 22:01:07 -07:00
|
|
|
Self {
|
2022-05-16 12:30:37 -07:00
|
|
|
fee_calculator: *fee_calculator,
|
2020-10-28 22:01:07 -07:00
|
|
|
}
|
2019-11-04 12:31:24 -08:00
|
|
|
}
|
2019-05-30 15:18:48 -07:00
|
|
|
}
|
|
|
|
|
2021-04-12 16:04:57 -07:00
|
|
|
impl Sysvar for Fees {
|
|
|
|
impl_sysvar_get!(sol_get_fees_sysvar);
|
|
|
|
}
|
2022-05-16 12:30:37 -07:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_clone() {
|
|
|
|
let fees = Fees {
|
|
|
|
fee_calculator: FeeCalculator {
|
|
|
|
lamports_per_signature: 1,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
let cloned_fees = fees.clone();
|
|
|
|
assert_eq!(cloned_fees, fees);
|
|
|
|
}
|
|
|
|
}
|