forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d484b3
commit cebf52d
Showing
5 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::{program_error::ProgramError, pubkey::Pubkey}; | ||
|
||
/// Get the current epoch stake for a given vote account. | ||
/// Returns `0` for any provided pubkey that isn't a vote account. | ||
pub fn get_epoch_stake(vote_address: &Pubkey) -> Result<u64, ProgramError> { | ||
let mut var = 0u64; | ||
let var_addr = &mut var as *mut _ as *mut u8; | ||
|
||
let vote_address = vote_address as *const _ as *const u8; | ||
|
||
#[cfg(target_os = "solana")] | ||
let result = unsafe { crate::syscalls::sol_syscall_get_epoch_stake(var_addr, vote_address) }; | ||
|
||
#[cfg(not(target_os = "solana"))] | ||
let result = crate::program_stubs::sol_syscall_get_epoch_stake(var_addr, vote_address); | ||
|
||
match result { | ||
crate::entrypoint::SUCCESS => Ok(var), | ||
e => Err(e.into()), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters