Simplifies return_data accessors in InvokeContext. (#20290)
This commit is contained in:
committed by
GitHub
parent
57c8abf499
commit
4de5fff3ca
@ -69,8 +69,7 @@ pub struct ThisInvokeContext<'a> {
|
||||
sysvars: RefCell<Vec<(Pubkey, Option<Rc<Vec<u8>>>)>>,
|
||||
blockhash: &'a Hash,
|
||||
fee_calculator: &'a FeeCalculator,
|
||||
// return data and program_id that set it
|
||||
return_data: Option<(Pubkey, Vec<u8>)>,
|
||||
return_data: (Pubkey, Vec<u8>),
|
||||
}
|
||||
impl<'a> ThisInvokeContext<'a> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
@ -109,7 +108,7 @@ impl<'a> ThisInvokeContext<'a> {
|
||||
sysvars: RefCell::new(vec![]),
|
||||
blockhash,
|
||||
fee_calculator,
|
||||
return_data: None,
|
||||
return_data: (Pubkey::default(), Vec::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -428,11 +427,12 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
|
||||
fn get_fee_calculator(&self) -> &FeeCalculator {
|
||||
self.fee_calculator
|
||||
}
|
||||
fn set_return_data(&mut self, return_data: Option<(Pubkey, Vec<u8>)>) {
|
||||
self.return_data = return_data;
|
||||
fn set_return_data(&mut self, data: Vec<u8>) -> Result<(), InstructionError> {
|
||||
self.return_data = (*self.get_caller()?, data);
|
||||
Ok(())
|
||||
}
|
||||
fn get_return_data(&self) -> &Option<(Pubkey, Vec<u8>)> {
|
||||
&self.return_data
|
||||
fn get_return_data(&self) -> (Pubkey, &[u8]) {
|
||||
(self.return_data.0, &self.return_data.1)
|
||||
}
|
||||
}
|
||||
pub struct ThisLogger {
|
||||
|
Reference in New Issue
Block a user