Add msg! macro for program logging, deprecate info! macro (#13885)

(cherry picked from commit 6705b5a98c)

Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
mergify[bot]
2020-12-01 06:05:31 +00:00
committed by GitHub
parent 4f4a0b9dc8
commit 3955778cb6
20 changed files with 158 additions and 137 deletions

View File

@@ -2,7 +2,7 @@
extern crate solana_program;
use solana_program::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, info,
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg,
program_error::ProgramError, pubkey::Pubkey,
};
@@ -14,36 +14,36 @@ fn process_instruction(
) -> ProgramResult {
match instruction_data[0] {
1 => {
info!("modify first account data");
msg!("modify first account data");
accounts[2].data.borrow_mut()[0] = 1;
}
2 => {
info!("modify first account data");
msg!("modify first account data");
accounts[3].data.borrow_mut()[0] = 2;
}
3 => {
info!("modify both account data");
msg!("modify both account data");
accounts[2].data.borrow_mut()[0] += 1;
accounts[3].data.borrow_mut()[0] += 2;
}
4 => {
info!("modify first account lamports");
msg!("modify first account lamports");
**accounts[1].lamports.borrow_mut() -= 1;
**accounts[2].lamports.borrow_mut() += 1;
}
5 => {
info!("modify first account lamports");
msg!("modify first account lamports");
**accounts[1].lamports.borrow_mut() -= 2;
**accounts[3].lamports.borrow_mut() += 2;
}
6 => {
info!("modify both account lamports");
msg!("modify both account lamports");
**accounts[1].lamports.borrow_mut() -= 3;
**accounts[2].lamports.borrow_mut() += 1;
**accounts[3].lamports.borrow_mut() += 2;
}
_ => {
info!("Unrecognized command");
msg!("Unrecognized command");
return Err(ProgramError::InvalidArgument);
}
}