Update get recent blockhashes to return confirmed blockhashes only
This commit is contained in:
parent
1dac4c33b8
commit
1db80d79fc
|
@ -299,12 +299,13 @@ impl ReplayStage {
|
||||||
) where
|
) where
|
||||||
T: 'static + KeypairUtil + Send + Sync,
|
T: 'static + KeypairUtil + Send + Sync,
|
||||||
{
|
{
|
||||||
|
if let Some(new_root) = locktower.record_vote(bank.slot()) {
|
||||||
|
bank_forks.write().unwrap().set_root(new_root);
|
||||||
|
blocktree.set_root(new_root);
|
||||||
|
Self::handle_new_root(&bank_forks, progress);
|
||||||
|
}
|
||||||
|
locktower.update_epoch(&bank);
|
||||||
if let Some(ref voting_keypair) = voting_keypair {
|
if let Some(ref voting_keypair) = voting_keypair {
|
||||||
if let Some(new_root) = locktower.record_vote(bank.slot()) {
|
|
||||||
bank_forks.write().unwrap().set_root(new_root);
|
|
||||||
blocktree.set_root(new_root);
|
|
||||||
Self::handle_new_root(&bank_forks, progress);
|
|
||||||
}
|
|
||||||
// Send our last few votes along with the new one
|
// Send our last few votes along with the new one
|
||||||
let vote_ix = vote_instruction::vote(vote_account_pubkey, locktower.recent_votes());
|
let vote_ix = vote_instruction::vote(vote_account_pubkey, locktower.recent_votes());
|
||||||
let vote_tx = Transaction::new_signed_instructions(
|
let vote_tx = Transaction::new_signed_instructions(
|
||||||
|
@ -312,7 +313,6 @@ impl ReplayStage {
|
||||||
vec![vote_ix],
|
vec![vote_ix],
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
);
|
);
|
||||||
locktower.update_epoch(&bank);
|
|
||||||
cluster_info.write().unwrap().push_vote(vote_tx);
|
cluster_info.write().unwrap().push_vote(vote_tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl JsonRpcRequestProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_recent_blockhash(&self) -> String {
|
fn get_recent_blockhash(&self) -> String {
|
||||||
let id = self.bank().last_blockhash();
|
let id = self.bank().get_confirmed_blockhash();
|
||||||
bs58::encode(id).into_string()
|
bs58::encode(id).into_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ impl RpcSol for RpcSolImpl {
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.bank()
|
.bank()
|
||||||
.last_blockhash();
|
.get_confirmed_blockhash();
|
||||||
let transaction = request_airdrop_transaction(&drone_addr, &pubkey, lamports, blockhash)
|
let transaction = request_airdrop_transaction(&drone_addr, &pubkey, lamports, blockhash)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
info!("request_airdrop_transaction failed: {:?}", err);
|
info!("request_airdrop_transaction failed: {:?}", err);
|
||||||
|
@ -450,7 +450,7 @@ mod tests {
|
||||||
let bank = bank_forks.read().unwrap().working_bank();
|
let bank = bank_forks.read().unwrap().working_bank();
|
||||||
let exit = Arc::new(AtomicBool::new(false));
|
let exit = Arc::new(AtomicBool::new(false));
|
||||||
|
|
||||||
let blockhash = bank.last_blockhash();
|
let blockhash = bank.get_confirmed_blockhash();
|
||||||
let tx = system_transaction::transfer(&alice, pubkey, 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, pubkey, 20, blockhash, 0);
|
||||||
bank.process_transaction(&tx).expect("process transaction");
|
bank.process_transaction(&tx).expect("process transaction");
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ mod tests {
|
||||||
&exit,
|
&exit,
|
||||||
);
|
);
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let blockhash = bank.last_blockhash();
|
let blockhash = bank.get_confirmed_blockhash();
|
||||||
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
|
||||||
bank.process_transaction(&tx).expect("process transaction");
|
bank.process_transaction(&tx).expect("process transaction");
|
||||||
})
|
})
|
||||||
|
|
|
@ -382,6 +382,14 @@ impl Bank {
|
||||||
pub fn last_blockhash(&self) -> Hash {
|
pub fn last_blockhash(&self) -> Hash {
|
||||||
self.blockhash_queue.read().unwrap().last_hash()
|
self.blockhash_queue.read().unwrap().last_hash()
|
||||||
}
|
}
|
||||||
|
/// Return the root bank's blockhash
|
||||||
|
pub fn get_confirmed_blockhash(&self) -> Hash {
|
||||||
|
if let Some(bank) = self.parents().last() {
|
||||||
|
bank.last_blockhash()
|
||||||
|
} else {
|
||||||
|
self.last_blockhash()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Forget all signatures. Useful for benchmarking.
|
/// Forget all signatures. Useful for benchmarking.
|
||||||
pub fn clear_signatures(&self) {
|
pub fn clear_signatures(&self) {
|
||||||
|
|
Loading…
Reference in New Issue