Reduce remaining program crates to boilerplate crates

This commit is contained in:
Greg Fitzgerald
2019-03-22 06:47:05 -06:00
committed by Grimes
parent 0a5b6154e8
commit 38fdbbba3f
20 changed files with 765 additions and 758 deletions

View File

@@ -1,44 +1,3 @@
//! Vote program
//! Receive and processes votes from validators
use solana_vote_api::vote_processor::process_instruction;
use bincode::deserialize;
use log::*;
use solana_sdk::account::KeyedAccount;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::solana_entrypoint;
use solana_sdk::transaction::InstructionError;
use solana_vote_api::vote_instruction::VoteInstruction;
use solana_vote_api::vote_state;
solana_entrypoint!(entrypoint);
fn entrypoint(
_program_id: &Pubkey,
keyed_accounts: &mut [KeyedAccount],
data: &[u8],
_tick_height: u64,
) -> Result<(), InstructionError> {
solana_logger::setup();
trace!("process_instruction: {:?}", data);
trace!("keyed_accounts: {:?}", keyed_accounts);
match deserialize(data).map_err(|_| InstructionError::InvalidInstructionData)? {
VoteInstruction::InitializeAccount => vote_state::initialize_account(keyed_accounts),
VoteInstruction::DelegateStake(delegate_id) => {
vote_state::delegate_stake(keyed_accounts, &delegate_id)
}
VoteInstruction::AuthorizeVoter(voter_id) => {
vote_state::authorize_voter(keyed_accounts, &voter_id)
}
VoteInstruction::Vote(vote) => {
debug!("{:?} by {}", vote, keyed_accounts[0].signer_key().unwrap());
solana_metrics::submit(
solana_metrics::influxdb::Point::new("vote-native")
.add_field("count", solana_metrics::influxdb::Value::Integer(1))
.to_owned(),
);
vote_state::process_vote(keyed_accounts, vote)
}
VoteInstruction::ClearCredits => vote_state::clear_credits(keyed_accounts),
}
}
solana_sdk::process_instruction_entrypoint!(process_instruction);