Skip to content

Commit

Permalink
Implements account resizing in BorrowedAccount.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Feb 1, 2022
1 parent 05234f9 commit 987d3fc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sdk/src/transaction_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,15 @@ impl<'a> BorrowedAccount<'a> {
self.verify_writability()
}

/*pub fn realloc(&self, new_len: usize, zero_init: bool) {
/// Resizes the account data (transaction wide)
///
/// Fills it with zeros at the end if is extended or truncates at the end otherwise.
pub fn set_data_length(&mut self, new_len: usize) -> Result<(), InstructionError> {
self.account.data_mut().resize(new_len, 0);
// TODO: return Err(InstructionError::InvalidRealloc);
// TODO: return Err(InstructionError::AccountDataSizeChanged);
}*/
self.verify_writability()
}

/// Deserializes the account data into a state
pub fn get_state<T: serde::de::DeserializeOwned>(&self) -> Result<T, InstructionError> {
Expand Down

0 comments on commit 987d3fc

Please sign in to comment.