program log pubkey as base58 (bp #12901) (#12910)

* program log pubkey as base58 (#12901)

(cherry picked from commit 3f9e6a600b)

# Conflicts:
#	programs/bpf/benches/bpf_loader.rs
#	programs/bpf/c/src/tuner/tuner.c
#	programs/bpf_loader/src/syscalls.rs
#	runtime/src/process_instruction.rs

* fix conflicts

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-10-15 19:21:27 +00:00
committed by GitHub
parent 0da2f73eb4
commit 782ed192b6
9 changed files with 135 additions and 27 deletions

View File

@@ -2,7 +2,7 @@
#![cfg(feature = "program")]
use crate::{account_info::AccountInfo, pubkey::Pubkey};
use crate::account_info::AccountInfo;
/// Prints a string
/// There are two forms and are fast
@@ -63,18 +63,6 @@ pub fn sol_log_slice(slice: &[u8]) {
}
}
/// Prints a pubkey
pub trait Log {
fn log(&self);
}
impl Log for Pubkey {
fn log(&self) {
for (i, k) in self.to_bytes().iter().enumerate() {
info!(0, 0, 0, i, *k);
}
}
}
/// Prints the hexadecimal representation of the program's input parameters
///
/// @param ka - A pointer to an array of `AccountInfo` to print

View File

@@ -201,9 +201,16 @@ impl Pubkey {
pub fn to_bytes(self) -> [u8; 32] {
self.0
}
}
// TODO localalize this
/// Log a `Pubkey` from a program
#[cfg(feature = "program")]
pub fn log(&self) {
extern "C" {
fn sol_log_pubkey(pubkey_addr: *const u8);
};
unsafe { sol_log_pubkey(self.as_ref() as *const _ as *const u8) };
}
}
impl AsRef<[u8]> for Pubkey {
fn as_ref(&self) -> &[u8] {