switch vote program to use slot height instead of tick height, change confirmation computation to use slots

This commit is contained in:
Carl
2019-02-21 00:44:37 -08:00
committed by Greg Fitzgerald
parent 20fffd8abf
commit 9e1c5e1ab0
5 changed files with 46 additions and 27 deletions

View File

@ -27,13 +27,13 @@ pub const MAX_VOTE_HISTORY: usize = 32;
#[derive(Serialize, Default, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct Vote {
// TODO: add signature of the state here as well
/// A vote for height tick_height
pub tick_height: u64,
/// A vote for height slot_height
pub slot_height: u64,
}
impl Vote {
pub fn new(tick_height: u64) -> Self {
Self { tick_height }
pub fn new(slot_height: u64) -> Self {
Self { slot_height }
}
}

View File

@ -14,11 +14,11 @@ pub struct VoteTransaction {}
impl VoteTransaction {
pub fn new_vote<T: KeypairUtil>(
voting_keypair: &T,
tick_height: u64,
slot_height: u64,
last_id: Hash,
fee: u64,
) -> Transaction {
let vote = Vote { tick_height };
let vote = Vote { slot_height };
let instruction = VoteInstruction::Vote(vote);
Transaction::new(
voting_keypair,
@ -81,12 +81,12 @@ mod tests {
#[test]
fn test_get_votes() {
let keypair = Keypair::new();
let tick_height = 1;
let slot_height = 1;
let last_id = Hash::default();
let transaction = VoteTransaction::new_vote(&keypair, tick_height, last_id, 0);
let transaction = VoteTransaction::new_vote(&keypair, slot_height, last_id, 0);
assert_eq!(
VoteTransaction::get_votes(&transaction),
vec![(keypair.pubkey(), Vote::new(tick_height), last_id)]
vec![(keypair.pubkey(), Vote::new(slot_height), last_id)]
);
}
}