Я использую proc_macro
и хочу напечатать несколько подробностей для отладки. Оператор println!
ничего не печатает.
Это вызов макроса:
decl_module! {
/// The module declaration.
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
// A default function for depositing events
fn deposit_event() = default;
/// Allow a user to claim ownership of an unclaimed proof
fn create_claim(origin, proof: Vec<u8>) -> DispatchResult {
// Verify that the incoming transaction is signed and store who the
// caller of this function is.
let sender = ensure_signed(origin)?;
println!("send is: {}", sender);
// Verify that the specified proof has not been claimed yet or error with the message
ensure!(!Proofs::<T>::exists(&proof), "This proof has already been claimed.");
// Call the `system` pallet to get the current block number
let current_block = <system::Module<T>>::block_number();
// Store the proof with the sender and the current block number
Proofs::<T>::insert(&proof, (sender.clone(), current_block));
// Emit an event that the claim was created
Self::deposit_event(RawEvent::ClaimCreated(sender, proof));
Ok(())
}
/// Allow the owner to revoke their claim
fn revoke_claim(origin, proof: Vec<u8>) -> DispatchResult {
// Determine who is calling the function
let sender = ensure_signed(origin)?;
// Verify that the specified proof has been claimed
ensure!(Proofs::<T>::exists(&proof), "This proof has not been stored yet.");
// Get owner of the claim
let (owner, _) = Proofs::<T>::get(&proof);
// Verify that sender of the current call is the claim owner
ensure!(sender == owner, "You must own this claim to revoke it.");
// Remove claim from storage
Proofs::<T>::remove(&proof);
// Emit an event that the claim was erased
Self::deposit_event(RawEvent::ClaimRevoked(sender, proof));
Ok(())
}
}
}
Он взят из здесь . Я добавил следующую строку:
println!("send is: {}", sender);
Я запускаю блокчейн (Polkadot dApp), в терминале (или где-либо еще) я не вижу выходного сообщения. Примечание: все работает нормально, но я не могу напечатать.