Fix undesired rollback
This commit is contained in:
parent
074c1bad60
commit
3aa2a8b542
|
@ -3,4 +3,5 @@ allow_backup = true
|
|||
allow_send = true
|
||||
|
||||
yec = { db_path = "./yec.db", lwd_url = "https://lite.ycash.xyz:9067" }
|
||||
zec = { db_path = "./zec.db", lwd_url = "https://mainnet.lightwalletd.com:9067" }
|
||||
zec = { db_path = "./zec.db", lwd_url = "https://lwdv3.zecwallet.co:443" }
|
||||
# zec = { db_path = "./zec.db", lwd_url = "https://zuul.free2z.cash:9067" }
|
||||
|
|
|
@ -121,6 +121,11 @@ pub async fn download_chain(
|
|||
.into_inner();
|
||||
while let Some(mut block) = block_stream.message().await? {
|
||||
if prev_hash.is_some() && block.prev_hash.as_slice() != prev_hash.unwrap() {
|
||||
log::warn!(
|
||||
"Reorg: {} != {}",
|
||||
hex::encode(block.prev_hash.as_slice()),
|
||||
hex::encode(prev_hash.unwrap())
|
||||
);
|
||||
anyhow::bail!(ChainError::Reorg);
|
||||
}
|
||||
let mut ph = [0u8; 32];
|
||||
|
|
|
@ -116,6 +116,9 @@ pub async fn sync_async(
|
|||
};
|
||||
let end_height = get_latest_height(&mut client).await?;
|
||||
let end_height = (end_height - target_height_offset).max(start_height);
|
||||
if start_height >= end_height {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let decrypter = DecryptNode::new(vks);
|
||||
|
||||
|
|
Loading…
Reference in New Issue