|
26 | 26 | //! [`RpcClient`]: https://docs.rs/solana-rpc-client/latest/solana_rpc_client/rpc_client/struct.RpcClient.html |
27 | 27 | //! [`env_logger`]: https://docs.rs/env_logger |
28 | 28 | //! [`RpcClient::get_transaction`]: https://docs.rs/solana-rpc-client/latest/solana_rpc_client/rpc_client/struct.RpcClient.html#method.get_transaction |
29 | | -//! |
30 | | -//! While most logging functions are defined in this module, [`Address`]es can |
31 | | -//! also be efficiently logged with the [`solana_address::log`] function. |
32 | | -//! |
33 | | -//! [`Address`]: solana_address::Address |
34 | 29 |
|
35 | 30 | use crate::account_info::AccountInfo; |
36 | 31 |
|
@@ -137,22 +132,28 @@ pub fn sol_log_slice(slice: &[u8]) { |
137 | 132 | /// - `accounts` - A slice of [`AccountInfo`]. |
138 | 133 | /// - `data` - The instruction data. |
139 | 134 | pub fn sol_log_params(accounts: &[AccountInfo], data: &[u8]) { |
140 | | - for (i, account) in accounts.iter().enumerate() { |
141 | | - msg!("AccountInfo"); |
142 | | - sol_log_64(0, 0, 0, 0, i as u64); |
143 | | - msg!("- Is signer"); |
144 | | - sol_log_64(0, 0, 0, 0, account.is_signer() as u64); |
145 | | - msg!("- Key"); |
146 | | - account.key().log(); |
147 | | - msg!("- Lamports"); |
148 | | - sol_log_64(0, 0, 0, 0, account.lamports()); |
149 | | - msg!("- Account data length"); |
150 | | - sol_log_64(0, 0, 0, 0, account.data_len() as u64); |
151 | | - msg!("- Owner"); |
152 | | - account.owner().log(); |
| 135 | + #[cfg(target_os = "solana")] |
| 136 | + { |
| 137 | + for (i, account) in accounts.iter().enumerate() { |
| 138 | + msg!("AccountInfo"); |
| 139 | + sol_log_64(0, 0, 0, 0, i as u64); |
| 140 | + msg!("- Is signer"); |
| 141 | + sol_log_64(0, 0, 0, 0, account.is_signer() as u64); |
| 142 | + msg!("- Key"); |
| 143 | + account.key().log(); |
| 144 | + msg!("- Lamports"); |
| 145 | + sol_log_64(0, 0, 0, 0, account.lamports()); |
| 146 | + msg!("- Account data length"); |
| 147 | + sol_log_64(0, 0, 0, 0, account.data_len() as u64); |
| 148 | + msg!("- Owner"); |
| 149 | + account.owner().log(); |
| 150 | + } |
| 151 | + msg!("Instruction data"); |
| 152 | + sol_log_slice(data); |
153 | 153 | } |
154 | | - msg!("Instruction data"); |
155 | | - sol_log_slice(data); |
| 154 | + |
| 155 | + #[cfg(not(target_os = "solana"))] |
| 156 | + core::hint::black_box((accounts, data)); |
156 | 157 | } |
157 | 158 |
|
158 | 159 | /// Print the remaining compute units available to the program. |
|
0 commit comments