Reduce VoteSignerProxy to KeypairUtil
This commit is contained in:
@ -21,6 +21,8 @@ use solana_metrics::{influxdb, submit};
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::timing::duration_as_ms;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use solana_sdk::vote_transaction::VoteTransaction;
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::mpsc::RecvTimeoutError;
|
||||
@ -142,8 +144,10 @@ impl ReplayStage {
|
||||
}
|
||||
|
||||
if 0 == num_ticks_to_next_vote {
|
||||
if let Some(signer) = vote_signer_proxy {
|
||||
let vote = signer.validator_vote(bank);
|
||||
if let Some(vote_signer_proxy) = vote_signer_proxy {
|
||||
let keypair = vote_signer_proxy.as_ref();
|
||||
let vote =
|
||||
Transaction::vote_new(keypair, bank.tick_height(), bank.last_id(), 0);
|
||||
cluster_info.write().unwrap().push_vote(vote);
|
||||
}
|
||||
}
|
||||
@ -473,7 +477,8 @@ mod test {
|
||||
None,
|
||||
);
|
||||
|
||||
let vote = vote_signer_proxy.validator_vote(&bank);
|
||||
let keypair = vote_signer_proxy.as_ref();
|
||||
let vote = Transaction::vote_new(keypair, bank.tick_height(), bank.last_id(), 0);
|
||||
cluster_info_me.write().unwrap().push_vote(vote);
|
||||
|
||||
// Send ReplayStage an entry, should see it on the ledger writer receiver
|
||||
@ -579,7 +584,8 @@ mod test {
|
||||
None,
|
||||
);
|
||||
|
||||
let vote = vote_signer_proxy.validator_vote(&bank);
|
||||
let keypair = vote_signer_proxy.as_ref();
|
||||
let vote = Transaction::vote_new(keypair, bank.tick_height(), bank.last_id(), 0);
|
||||
cluster_info_me.write().unwrap().push_vote(vote);
|
||||
|
||||
// Send enough ticks to trigger leader rotation
|
||||
|
@ -7,7 +7,6 @@ use crate::db_ledger;
|
||||
use crate::erasure;
|
||||
use crate::packet;
|
||||
use crate::poh_recorder;
|
||||
use crate::vote_signer_proxy;
|
||||
use bincode;
|
||||
use serde_json;
|
||||
use std;
|
||||
@ -29,7 +28,6 @@ pub enum Error {
|
||||
ErasureError(erasure::ErasureError),
|
||||
SendError,
|
||||
PohRecorderError(poh_recorder::PohRecorderError),
|
||||
VoteError(vote_signer_proxy::VoteError),
|
||||
DbLedgerError(db_ledger::DbLedgerError),
|
||||
}
|
||||
|
||||
@ -104,11 +102,6 @@ impl std::convert::From<poh_recorder::PohRecorderError> for Error {
|
||||
Error::PohRecorderError(e)
|
||||
}
|
||||
}
|
||||
impl std::convert::From<vote_signer_proxy::VoteError> for Error {
|
||||
fn from(e: vote_signer_proxy::VoteError) -> Error {
|
||||
Error::VoteError(e)
|
||||
}
|
||||
}
|
||||
impl std::convert::From<db_ledger::DbLedgerError> for Error {
|
||||
fn from(e: db_ledger::DbLedgerError) -> Error {
|
||||
Error::DbLedgerError(e)
|
||||
|
@ -1,35 +1,22 @@
|
||||
//! The `vote_signer_proxy` votes on the `last_id` of the bank at a regular cadence
|
||||
|
||||
use crate::bank::Bank;
|
||||
use crate::jsonrpc_core;
|
||||
use crate::result::Result;
|
||||
use crate::rpc_request::{RpcClient, RpcRequest};
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use solana_sdk::vote_transaction::VoteTransaction;
|
||||
use solana_vote_signer::rpc::LocalVoteSigner;
|
||||
use solana_vote_signer::rpc::VoteSigner;
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum VoteError {
|
||||
NoValidSupermajority,
|
||||
NoLeader,
|
||||
LeaderInfoNotFound,
|
||||
}
|
||||
|
||||
pub struct RemoteVoteSigner {
|
||||
rpc_client: RpcClient,
|
||||
}
|
||||
|
||||
impl RemoteVoteSigner {
|
||||
pub fn new(signer: SocketAddr) -> Self {
|
||||
Self {
|
||||
rpc_client: RpcClient::new_from_socket(signer),
|
||||
}
|
||||
let rpc_client = RpcClient::new_from_socket(signer);
|
||||
Self { rpc_client }
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,21 +94,4 @@ impl VoteSignerProxy {
|
||||
pub fn new_local(keypair: &Arc<Keypair>) -> Self {
|
||||
Self::new_with_signer(keypair, Box::new(LocalVoteSigner::default()))
|
||||
}
|
||||
|
||||
pub fn new_vote_account(&self, bank: &Bank, num_tokens: u64, last_id: Hash) -> Result<()> {
|
||||
// Create and register the new vote account
|
||||
let tx =
|
||||
Transaction::vote_account_new(&self.keypair, self.vote_account, last_id, num_tokens, 0);
|
||||
bank.process_transaction(&tx)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn validator_vote(&self, bank: &Arc<Bank>) -> Transaction {
|
||||
Transaction::vote_new(self, bank.tick_height(), bank.last_id(), 0)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
//TODO simple tests that cover the signing
|
||||
}
|
||||
|
Reference in New Issue
Block a user