parent
56dc958116
commit
7d6ea6c17e
|
@ -4239,6 +4239,7 @@ dependencies = [
|
|||
"solana-logger 1.1.0",
|
||||
"solana-runtime 1.1.0",
|
||||
"solana-sdk 1.1.0",
|
||||
"solana-stake-program 1.1.0",
|
||||
"solana-vote-program 1.1.0",
|
||||
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
|
@ -20,6 +20,7 @@ solana-logger = { path = "../logger", version = "1.1.0" }
|
|||
solana-runtime = { path = "../runtime", version = "1.1.0" }
|
||||
solana-sdk = { path = "../sdk", version = "1.1.0" }
|
||||
solana-vote-program = { path = "../programs/vote", version = "1.1.0" }
|
||||
solana-stake-program = { path = "../programs/stake", version = "1.1.0" }
|
||||
tempfile = "3.1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -36,6 +36,32 @@ enum LedgerOutputMethod {
|
|||
Json,
|
||||
}
|
||||
|
||||
fn output_slot_rewards(
|
||||
blockstore: &Blockstore,
|
||||
slot: Slot,
|
||||
method: &LedgerOutputMethod,
|
||||
) -> Result<(), String> {
|
||||
// Note: rewards are not output in JSON yet
|
||||
if *method == LedgerOutputMethod::Print {
|
||||
if let Ok(rewards) = blockstore.read_rewards(slot) {
|
||||
if let Some(rewards) = rewards {
|
||||
if !rewards.is_empty() {
|
||||
println!(" Rewards:");
|
||||
for reward in rewards {
|
||||
println!(
|
||||
" Account {}: {}{} SOL",
|
||||
reward.pubkey,
|
||||
if reward.lamports < 0 { '-' } else { ' ' },
|
||||
lamports_to_sol(reward.lamports.abs().try_into().unwrap())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn output_slot(
|
||||
blockstore: &Blockstore,
|
||||
slot: Slot,
|
||||
|
@ -94,6 +120,15 @@ fn output_slot(
|
|||
println!(" {:?}", vote_instruction);
|
||||
raw = false;
|
||||
}
|
||||
} else if program_pubkey == solana_stake_program::id() {
|
||||
if let Ok(stake_instruction) =
|
||||
limited_deserialize::<
|
||||
solana_stake_program::stake_instruction::StakeInstruction,
|
||||
>(&instruction.data)
|
||||
{
|
||||
println!(" {:?}", stake_instruction);
|
||||
raw = false;
|
||||
}
|
||||
} else if program_pubkey == solana_sdk::system_program::id() {
|
||||
if let Ok(system_instruction) =
|
||||
limited_deserialize::<
|
||||
|
@ -164,25 +199,7 @@ fn output_slot(
|
|||
}
|
||||
}
|
||||
|
||||
// Note: rewards are not output in JSON yet
|
||||
if *method == LedgerOutputMethod::Print {
|
||||
if let Ok(rewards) = blockstore.read_rewards(slot) {
|
||||
if let Some(rewards) = rewards {
|
||||
if !rewards.is_empty() {
|
||||
println!(" Rewards:");
|
||||
for reward in rewards {
|
||||
println!(
|
||||
" Account {}: {}{} SOL",
|
||||
reward.pubkey,
|
||||
if reward.lamports < 0 { '-' } else { ' ' },
|
||||
lamports_to_sol(reward.lamports.abs().try_into().unwrap())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
output_slot_rewards(blockstore, slot, method)
|
||||
}
|
||||
|
||||
fn output_ledger(blockstore: Blockstore, starting_slot: Slot, method: LedgerOutputMethod) {
|
||||
|
|
Loading…
Reference in New Issue