Purge remaining last_id (now called block_hash)
This commit is contained in:
committed by
Greg Fitzgerald
parent
2bfad87a5f
commit
258cf21416
@@ -24,8 +24,8 @@ impl<'a> RewardsBank<'a> {
|
||||
rewards_id: Pubkey,
|
||||
lamports: u64,
|
||||
) -> Result<()> {
|
||||
let last_id = self.bank.last_block_hash();
|
||||
let tx = RewardsTransaction::new_account(from_keypair, rewards_id, last_id, lamports, 0);
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let tx = RewardsTransaction::new_account(from_keypair, rewards_id, block_hash, lamports, 0);
|
||||
self.bank.process_transaction(&tx)
|
||||
}
|
||||
|
||||
@@ -35,24 +35,24 @@ impl<'a> RewardsBank<'a> {
|
||||
vote_id: Pubkey,
|
||||
lamports: u64,
|
||||
) -> Result<()> {
|
||||
let last_id = self.bank.last_block_hash();
|
||||
let tx = VoteTransaction::fund_staking_account(from_keypair, vote_id, last_id, lamports, 0);
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let tx = VoteTransaction::fund_staking_account(from_keypair, vote_id, block_hash, lamports, 0);
|
||||
self.bank.process_transaction(&tx)
|
||||
}
|
||||
|
||||
fn submit_vote(&self, vote_keypair: &Keypair, tick_height: u64) -> Result<VoteState> {
|
||||
let last_id = self.bank.last_block_hash();
|
||||
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, last_id, 0);
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, block_hash, 0);
|
||||
self.bank.process_transaction(&tx)?;
|
||||
self.bank.register_tick(&hash(last_id.as_ref()));
|
||||
self.bank.register_tick(&hash(block_hash.as_ref()));
|
||||
|
||||
let vote_account = self.bank.get_account(&vote_keypair.pubkey()).unwrap();
|
||||
Ok(VoteState::deserialize(&vote_account.userdata).unwrap())
|
||||
}
|
||||
|
||||
fn redeem_credits(&self, rewards_id: Pubkey, vote_keypair: &Keypair) -> Result<VoteState> {
|
||||
let last_id = self.bank.last_block_hash();
|
||||
let tx = RewardsTransaction::new_redeem_credits(&vote_keypair, rewards_id, last_id, 0);
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let tx = RewardsTransaction::new_redeem_credits(&vote_keypair, rewards_id, block_hash, 0);
|
||||
self.bank.process_transaction(&tx)?;
|
||||
let vote_account = self.bank.get_account(&vote_keypair.pubkey()).unwrap();
|
||||
Ok(VoteState::deserialize(&vote_account.userdata).unwrap())
|
||||
|
@@ -18,14 +18,14 @@ impl RewardsTransaction {
|
||||
pub fn new_account(
|
||||
from_keypair: &Keypair,
|
||||
rewards_id: Pubkey,
|
||||
last_id: Hash,
|
||||
block_hash: Hash,
|
||||
num_tokens: u64,
|
||||
fee: u64,
|
||||
) -> Transaction {
|
||||
SystemTransaction::new_program_account(
|
||||
from_keypair,
|
||||
rewards_id,
|
||||
last_id,
|
||||
block_hash,
|
||||
num_tokens,
|
||||
RewardsState::max_size() as u64,
|
||||
id(),
|
||||
@@ -36,7 +36,7 @@ impl RewardsTransaction {
|
||||
pub fn new_redeem_credits(
|
||||
vote_keypair: &Keypair,
|
||||
rewards_id: Pubkey,
|
||||
last_id: Hash,
|
||||
block_hash: Hash,
|
||||
fee: u64,
|
||||
) -> Transaction {
|
||||
let vote_id = vote_keypair.pubkey();
|
||||
@@ -45,6 +45,6 @@ impl RewardsTransaction {
|
||||
vote_id, rewards_id,
|
||||
))
|
||||
.push(VoteInstruction::new_clear_credits(vote_id))
|
||||
.sign(&[vote_keypair], last_id)
|
||||
.sign(&[vote_keypair], block_hash)
|
||||
}
|
||||
}
|
||||
|
@@ -46,21 +46,21 @@ fn test_bank_storage() {
|
||||
let jill = Keypair::new();
|
||||
|
||||
let x = 42;
|
||||
let last_id = genesis_block.hash();
|
||||
let block_hash = genesis_block.hash();
|
||||
let x2 = x * 2;
|
||||
let storage_block_hash = hash(&[x2]);
|
||||
|
||||
bank.register_tick(&last_id);
|
||||
bank.register_tick(&block_hash);
|
||||
|
||||
bank.transfer(10, &alice, jill.pubkey(), last_id).unwrap();
|
||||
bank.transfer(10, &alice, jill.pubkey(), block_hash).unwrap();
|
||||
|
||||
bank.transfer(10, &alice, bob.pubkey(), last_id).unwrap();
|
||||
bank.transfer(10, &alice, jack.pubkey(), last_id).unwrap();
|
||||
bank.transfer(10, &alice, bob.pubkey(), block_hash).unwrap();
|
||||
bank.transfer(10, &alice, jack.pubkey(), block_hash).unwrap();
|
||||
|
||||
let tx = SystemTransaction::new_program_account(
|
||||
&alice,
|
||||
bob.pubkey(),
|
||||
last_id,
|
||||
block_hash,
|
||||
1,
|
||||
4 * 1024,
|
||||
storage_program::id(),
|
||||
@@ -72,7 +72,7 @@ fn test_bank_storage() {
|
||||
let tx = StorageTransaction::new_advertise_recent_block_hash(
|
||||
&bob,
|
||||
storage_block_hash,
|
||||
last_id,
|
||||
block_hash,
|
||||
ENTRIES_PER_SEGMENT,
|
||||
);
|
||||
|
||||
@@ -84,7 +84,7 @@ fn test_bank_storage() {
|
||||
//let tx = StorageTransaction::new_mining_proof(
|
||||
// &jack,
|
||||
// Hash::default(),
|
||||
// last_id,
|
||||
// block_hash,
|
||||
// entry_height,
|
||||
// Signature::default(),
|
||||
//);
|
||||
|
@@ -26,16 +26,16 @@ impl<'a> VoteBank<'a> {
|
||||
vote_id: Pubkey,
|
||||
lamports: u64,
|
||||
) -> Result<()> {
|
||||
let last_id = self.bank.last_block_hash();
|
||||
let tx = VoteTransaction::fund_staking_account(from_keypair, vote_id, last_id, lamports, 0);
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let tx = VoteTransaction::fund_staking_account(from_keypair, vote_id, block_hash, lamports, 0);
|
||||
self.bank.process_transaction(&tx)
|
||||
}
|
||||
|
||||
fn submit_vote(&self, vote_keypair: &Keypair, tick_height: u64) -> Result<VoteState> {
|
||||
let last_id = self.bank.last_block_hash();
|
||||
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, last_id, 0);
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, block_hash, 0);
|
||||
self.bank.process_transaction(&tx)?;
|
||||
self.bank.register_tick(&hash(last_id.as_ref()));
|
||||
self.bank.register_tick(&hash(block_hash.as_ref()));
|
||||
|
||||
let vote_account = self.bank.get_account(&vote_keypair.pubkey()).unwrap();
|
||||
Ok(VoteState::deserialize(&vote_account.userdata).unwrap())
|
||||
@@ -71,7 +71,7 @@ fn test_vote_via_bank_with_no_signature() {
|
||||
.unwrap();
|
||||
|
||||
let mallory_id = mallory_keypair.pubkey();
|
||||
let last_id = bank.last_block_hash();
|
||||
let block_hash = bank.last_block_hash();
|
||||
let vote_ix = BuilderInstruction::new(
|
||||
vote_program::id(),
|
||||
&VoteInstruction::Vote(Vote::new(0)),
|
||||
@@ -84,7 +84,7 @@ fn test_vote_via_bank_with_no_signature() {
|
||||
let tx = TransactionBuilder::default()
|
||||
.push(SystemInstruction::new_move(mallory_id, vote_id, 1))
|
||||
.push(vote_ix)
|
||||
.sign(&[&mallory_keypair], last_id);
|
||||
.sign(&[&mallory_keypair], block_hash);
|
||||
|
||||
let result = bank.process_transaction(&tx);
|
||||
|
||||
|
Reference in New Issue
Block a user