Bank gets accounts data len delta from MessageProcessor::process_message()

This commit is contained in:
Brooks Prumo
2021-12-15 16:41:38 -06:00
committed by GitHub
parent 46e5350d8c
commit 635337d2ff
2 changed files with 31 additions and 7 deletions

View File

@@ -34,6 +34,13 @@ impl ::solana_frozen_abi::abi_example::AbiExample for MessageProcessor {
}
}
/// Resultant information gathered from calling process_message()
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct ProcessedMessageInfo {
/// The amount that the accounts data len has changed
pub accounts_data_len_delta: i64,
}
impl MessageProcessor {
/// Process a message.
/// This method calls each instruction in the message over the set of loaded accounts.
@@ -56,7 +63,7 @@ impl MessageProcessor {
sysvars: &[(Pubkey, Vec<u8>)],
blockhash: Hash,
lamports_per_signature: u64,
) -> Result<(), TransactionError> {
) -> Result<ProcessedMessageInfo, TransactionError> {
let mut invoke_context = InvokeContext::new(
rent,
accounts,
@@ -118,7 +125,7 @@ impl MessageProcessor {
);
timings.accumulate(&invoke_context.timings);
}
Ok(())
Ok(ProcessedMessageInfo::default())
}
}
@@ -244,7 +251,7 @@ mod tests {
Hash::default(),
0,
);
assert_eq!(result, Ok(()));
assert!(result.is_ok());
assert_eq!(accounts[0].1.borrow().lamports(), 100);
assert_eq!(accounts[1].1.borrow().lamports(), 0);
@@ -483,7 +490,7 @@ mod tests {
Hash::default(),
0,
);
assert_eq!(result, Ok(()));
assert!(result.is_ok());
// Do work on the same account but at different location in keyed_accounts[]
let message = Message::new(
@@ -513,7 +520,7 @@ mod tests {
Hash::default(),
0,
);
assert_eq!(result, Ok(()));
assert!(result.is_ok());
assert_eq!(accounts[0].1.borrow().lamports(), 80);
assert_eq!(accounts[1].1.borrow().lamports(), 20);
assert_eq!(accounts[0].1.borrow().data(), &vec![42]);