Use trace! inside solitaire
Change-Id: Ic26fcabbb6d6000b306d190aab306307ab9cda7f
This commit is contained in:
parent
18e52aafe6
commit
af00a3c02a
|
@ -40,9 +40,8 @@ macro_rules! solitaire {
|
||||||
entrypoint::ProgramResult,
|
entrypoint::ProgramResult,
|
||||||
program_error::ProgramError,
|
program_error::ProgramError,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
msg,
|
|
||||||
};
|
};
|
||||||
use solitaire::{FromAccounts, Persist, Result};
|
use solitaire::{FromAccounts, Persist, Result, trace};
|
||||||
|
|
||||||
/// Generated:
|
/// Generated:
|
||||||
/// This Instruction contains a 1-1 mapping for each enum variant to function call. The
|
/// This Instruction contains a 1-1 mapping for each enum variant to function call. The
|
||||||
|
@ -59,7 +58,7 @@ macro_rules! solitaire {
|
||||||
match Instruction::try_from_slice(d).map_err(|e| SolitaireError::InstructionDeserializeFailed(e))? {
|
match Instruction::try_from_slice(d).map_err(|e| SolitaireError::InstructionDeserializeFailed(e))? {
|
||||||
$(
|
$(
|
||||||
Instruction::$row(ix_data) => {
|
Instruction::$row(ix_data) => {
|
||||||
msg!("Dispatch: {}", stringify!($row));
|
trace!("Dispatch: {}", stringify!($row));
|
||||||
let (mut accounts): ($row) = FromAccounts::from(p, &mut a.iter(), &())?;
|
let (mut accounts): ($row) = FromAccounts::from(p, &mut a.iter(), &())?;
|
||||||
$fn(&ExecutionContext{program_id: p, accounts: a}, &mut accounts, ix_data)?;
|
$fn(&ExecutionContext{program_id: p, accounts: a}, &mut accounts, ix_data)?;
|
||||||
Persist::persist(&accounts, p)?;
|
Persist::persist(&accounts, p)?;
|
||||||
|
@ -74,9 +73,9 @@ macro_rules! solitaire {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn solitaire<'a, 'b: 'a>(p: &Pubkey, a: &'a [AccountInfo<'b>], d: &[u8]) -> ProgramResult {
|
pub fn solitaire<'a, 'b: 'a>(p: &Pubkey, a: &'a [AccountInfo<'b>], d: &[u8]) -> ProgramResult {
|
||||||
solana_program::msg!(&format!("{} {} built with {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"), solitaire::PKG_NAME_VERSION));
|
trace!("{} {} built with {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"), solitaire::PKG_NAME_VERSION);
|
||||||
if let Err(err) = dispatch(p, a, d) {
|
if let Err(err) = dispatch(p, a, d) {
|
||||||
solana_program::msg!("Error: {:?}", err);
|
trace!("Error: {:?}", err);
|
||||||
return Err(err.into());
|
return Err(err.into());
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -6,6 +6,7 @@ use solana_program::{
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
};
|
};
|
||||||
use std::slice::Iter;
|
use std::slice::Iter;
|
||||||
|
use crate::trace;
|
||||||
|
|
||||||
/// The context is threaded through each check. Include anything within this structure that you
|
/// The context is threaded through each check. Include anything within this structure that you
|
||||||
/// would like to have access to as each layer of dependency is peeled off.
|
/// would like to have access to as each layer of dependency is peeled off.
|
||||||
|
@ -36,6 +37,7 @@ impl<'a, 'b: 'a, 'c, T> Context<'a, 'b, 'c, T> {
|
||||||
match self.info {
|
match self.info {
|
||||||
None => {
|
None => {
|
||||||
let info = next_account_info(self.iter).unwrap();
|
let info = next_account_info(self.iter).unwrap();
|
||||||
|
trace!("{}", info.key);
|
||||||
self.info = Some(info);
|
self.info = Some(info);
|
||||||
info
|
info
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,12 +163,10 @@ fn generate_fields(name: &syn::Ident, data: &Data) -> TokenStream2 {
|
||||||
let recurse = fields.named.iter().map(|f| {
|
let recurse = fields.named.iter().map(|f| {
|
||||||
// Field name, to assign to.
|
// Field name, to assign to.
|
||||||
let name = &f.ident;
|
let name = &f.ident;
|
||||||
let name_string =
|
|
||||||
format!("Peeling: {}", name.to_token_stream().to_string());
|
|
||||||
let ty = &f.ty;
|
let ty = &f.ty;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
solana_program::msg!(#name_string);
|
trace!(stringify!(#name));
|
||||||
let #name: #ty = solitaire::Peel::peel(&mut solitaire::Context::new(
|
let #name: #ty = solitaire::Peel::peel(&mut solitaire::Context::new(
|
||||||
pid,
|
pid,
|
||||||
iter,
|
iter,
|
||||||
|
@ -185,6 +183,8 @@ fn generate_fields(name: &syn::Ident, data: &Data) -> TokenStream2 {
|
||||||
// Write out our iterator and return the filled structure.
|
// Write out our iterator and return the filled structure.
|
||||||
quote! {
|
quote! {
|
||||||
use solana_program::account_info::next_account_info;
|
use solana_program::account_info::next_account_info;
|
||||||
|
use solitaire::trace;
|
||||||
|
trace!("Peeling:");
|
||||||
#(#recurse;)*
|
#(#recurse;)*
|
||||||
Ok(#name { #(#names,)* })
|
Ok(#name { #(#names,)* })
|
||||||
}
|
}
|
||||||
|
@ -261,12 +261,15 @@ fn generate_persist(name: &syn::Ident, data: &Data) -> TokenStream2 {
|
||||||
let ty = &f.ty;
|
let ty = &f.ty;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
trace!(stringify!(#name));
|
||||||
Peel::persist(&self.#name, program_id)?;
|
Peel::persist(&self.#name, program_id)?;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Write out our iterator and return the filled structure.
|
// Write out our iterator and return the filled structure.
|
||||||
quote! {
|
quote! {
|
||||||
|
use solitaire::trace;
|
||||||
|
trace!("Persisting:");
|
||||||
#(#recurse;)*
|
#(#recurse;)*
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue