processor.rs 931 B

1234567891011121314151617181920212223242526
  1. use crate::instructions::*;
  2. use crate::state::*;
  3. use borsh::{BorshDeserialize, BorshSerialize};
  4. use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};
  5. #[derive(BorshSerialize, BorshDeserialize, Debug)]
  6. pub enum ReallocInstruction {
  7. Create(AddressInfo),
  8. ReallocateWithoutZeroInit(EnhancedAddressInfoExtender),
  9. ReallocateZeroInit(WorkInfo),
  10. }
  11. pub fn process_instruction(
  12. program_id: &Pubkey,
  13. accounts: &[AccountInfo],
  14. input: &[u8],
  15. ) -> ProgramResult {
  16. let instruction = ReallocInstruction::try_from_slice(input)?;
  17. match instruction {
  18. ReallocInstruction::Create(data) => create_address_info(program_id, accounts, data),
  19. ReallocInstruction::ReallocateWithoutZeroInit(data) => {
  20. reallocate_without_zero_init(accounts, data)
  21. }
  22. ReallocInstruction::ReallocateZeroInit(data) => reallocate_zero_init(accounts, data),
  23. }
  24. }