solana-flux-aggregator/integration-example/src/entrypoint.rs

36 lines
955 B
Rust

use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint,
msg,
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 {
let accounts_iter = &mut accounts.iter();
// the account to store data
let aggregator_info = next_account_info(accounts_iter)?;
let value = flux_aggregator::get_median(aggregator_info)?;
// show the value and then return error
// to demonstrate we've got the aggregator value
msg!(&format!("aggregator value: {:?}", value));
return Err(ProgramError::MissingRequiredSignature);
}