committed by
GitHub
parent
f07c038266
commit
288ed7a8ea
@ -33,12 +33,12 @@ enum VoteError {
|
||||
NoValidLastIdsToVoteOn,
|
||||
}
|
||||
|
||||
pub fn create_vote_tx_and_blob(
|
||||
pub fn create_new_signed_vote_blob(
|
||||
last_id: &Hash,
|
||||
keypair: &Keypair,
|
||||
crdt: &Arc<RwLock<Crdt>>,
|
||||
blob_recycler: &BlobRecycler,
|
||||
) -> Result<(Transaction, SharedBlob)> {
|
||||
) -> Result<SharedBlob> {
|
||||
let shared_blob = blob_recycler.allocate();
|
||||
let (vote, addr) = {
|
||||
let mut wcrdt = crdt.write().unwrap();
|
||||
@ -55,7 +55,7 @@ pub fn create_vote_tx_and_blob(
|
||||
blob.meta.set_addr(&addr);
|
||||
blob.meta.size = len;
|
||||
}
|
||||
Ok((tx, shared_blob))
|
||||
Ok(shared_blob)
|
||||
}
|
||||
|
||||
fn get_last_id_to_vote_on(
|
||||
@ -139,10 +139,9 @@ pub fn send_leader_vote(
|
||||
last_vote,
|
||||
last_valid_validator_timestamp,
|
||||
) {
|
||||
if let Ok((tx, shared_blob)) =
|
||||
create_vote_tx_and_blob(&last_id, keypair, crdt, blob_recycler)
|
||||
if let Ok(shared_blob) =
|
||||
create_new_signed_vote_blob(&last_id, keypair, crdt, blob_recycler)
|
||||
{
|
||||
bank.process_transaction(&tx)?;
|
||||
vote_blob_sender.send(VecDeque::from(vec![shared_blob]))?;
|
||||
let finality_ms = now - super_majority_timestamp;
|
||||
|
||||
@ -172,7 +171,7 @@ fn send_validator_vote(
|
||||
vote_blob_sender: &BlobSender,
|
||||
) -> Result<()> {
|
||||
let last_id = bank.last_id();
|
||||
if let Ok((_, shared_blob)) = create_vote_tx_and_blob(&last_id, keypair, crdt, blob_recycler) {
|
||||
if let Ok(shared_blob) = create_new_signed_vote_blob(&last_id, keypair, crdt, blob_recycler) {
|
||||
inc_new_counter_info!("replicate-vote_sent", 1);
|
||||
|
||||
vote_blob_sender.send(VecDeque::from(vec![shared_blob]))?;
|
||||
@ -236,6 +235,7 @@ impl Service for VoteStage {
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use bank::Bank;
|
||||
use bincode::deserialize;
|
||||
use crdt::{Crdt, NodeInfo, TestNode};
|
||||
use entry::next_entry;
|
||||
use hash::{hash, Hash};
|
||||
@ -390,6 +390,11 @@ pub mod tests {
|
||||
|
||||
// leader should vote now
|
||||
assert!(vote_blob.is_ok());
|
||||
|
||||
// vote should be valid
|
||||
let blob = vote_blob.unwrap().pop_front().unwrap();
|
||||
let tx = deserialize(&(blob.read().unwrap().data)).unwrap();
|
||||
assert!(bank.process_transaction(&tx).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user