Use vote signer service in fullnode (#2009)

* Use vote signer service in fullnode

* Use native types for signature and pubkey, and address other review comments

* Start local vote signer if a remote service address is not provided

* Rebased to master

* Fixes after rebase
This commit is contained in:
Pankaj Garg
2019-01-05 12:57:52 -08:00
committed by GitHub
parent 71a2b794b4
commit 91bd38504e
23 changed files with 774 additions and 227 deletions

View File

@ -71,6 +71,21 @@ impl Transaction {
instructions,
)
}
pub fn new_unsigned<T: Serialize>(
from_pubkey: &Pubkey,
transaction_keys: &[Pubkey],
program_id: Pubkey,
userdata: &T,
last_id: Hash,
fee: u64,
) -> Self {
let program_ids = vec![program_id];
let accounts = (0..=transaction_keys.len() as u8).collect();
let instructions = vec![Instruction::new(0, userdata, accounts)];
let mut keys = vec![*from_pubkey];
keys.extend_from_slice(transaction_keys);
Self::new_with_instructions(&[], &keys[..], last_id, fee, program_ids, instructions)
}
/// Create a signed transaction
/// * `from_keypair` - The key used to sign the transaction. This key is stored as keys[0]
/// * `account_keys` - The keys for the transaction. These are the program state

View File

@ -10,7 +10,7 @@ use crate::vote_program::{self, Vote, VoteInstruction};
use bincode::deserialize;
pub trait VoteTransaction {
fn vote_new(vote_account: &Keypair, vote: Vote, last_id: Hash, fee: u64) -> Self;
fn vote_new(vote_account: &Pubkey, vote: Vote, last_id: Hash, fee: u64) -> Self;
fn vote_account_new(
validator_id: &Keypair,
vote_account_id: Pubkey,
@ -23,9 +23,9 @@ pub trait VoteTransaction {
}
impl VoteTransaction for Transaction {
fn vote_new(vote_account: &Keypair, vote: Vote, last_id: Hash, fee: u64) -> Self {
fn vote_new(vote_account: &Pubkey, vote: Vote, last_id: Hash, fee: u64) -> Self {
let instruction = VoteInstruction::NewVote(vote);
Transaction::new(
Transaction::new_unsigned(
vote_account,
&[],
vote_program::id(),