2020-12-09 07:38:31 -08:00
|
|
|
|
|
|
|
|
|
|
|
use solana_program::{
|
2020-12-10 01:39:46 -08:00
|
|
|
account_info::{next_account_info, AccountInfo},
|
|
|
|
entrypoint,
|
|
|
|
msg,
|
2020-12-09 07:38:31 -08:00
|
|
|
entrypoint::ProgramResult,
|
|
|
|
program_error::{ProgramError},
|
|
|
|
pubkey::Pubkey,
|
|
|
|
};
|
|
|
|
|
|
|
|
use flux_aggregator;
|
|
|
|
|
|
|
|
entrypoint!(process_instruction);
|
|
|
|
|
|
|
|
// Program entrypoint's implementation
|
|
|
|
fn process_instruction(
|
|
|
|
_program_id: &Pubkey, // Public key of the account the hello world program was loaded into
|
|
|
|
accounts: &[AccountInfo], // The account to say hello to
|
|
|
|
_instruction_data: &[u8], // A number to store
|
|
|
|
) -> ProgramResult {
|
2020-12-10 01:39:46 -08:00
|
|
|
|
2020-12-09 07:38:31 -08:00
|
|
|
let accounts_iter = &mut accounts.iter();
|
|
|
|
|
|
|
|
// the account to store data
|
|
|
|
let aggregator_info = next_account_info(accounts_iter)?;
|
|
|
|
|
2020-12-10 01:39:46 -08:00
|
|
|
let value = flux_aggregator::get_median(aggregator_info)?;
|
2020-12-09 07:38:31 -08:00
|
|
|
|
|
|
|
// show the value and then return error
|
|
|
|
// to demonstrate we've got the aggregator value
|
2020-12-10 01:39:46 -08:00
|
|
|
msg!(&format!("aggregator value: {:?}", value));
|
2020-12-09 07:38:31 -08:00
|
|
|
|
|
|
|
return Err(ProgramError::MissingRequiredSignature);
|
2020-12-10 01:39:46 -08:00
|
|
|
|
2020-12-09 07:38:31 -08:00
|
|
|
}
|