Skip to content

Commit

Permalink
Fix sync height
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeykoren committed Dec 10, 2024
1 parent 7458772 commit a4ba0f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/commands/test_orchard_zsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Runnable for TestOrchardZSACmd {
let balances = TestBalances::get_asset(asset, &mut wallet);
print_balances("=== Initial balances ===", asset, balances);

let current_height = (&mut wallet).last_block_height();
let current_height = wallet.last_block_height();
mine(
&mut wallet,
&mut rpc_client,
Expand Down
10 changes: 7 additions & 3 deletions src/components/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use orchard::value::NoteValue;
use orchard::Address;
use rand::rngs::OsRng;
use std::convert::TryFrom;
use std::ops::Add;
use zcash_primitives::block::{BlockHash, BlockHeader, BlockHeaderData};
use zcash_primitives::consensus::{BlockHeight, BranchId, RegtestNetwork, REGTEST_NETWORK};
use zcash_primitives::memo::MemoBytes;
Expand All @@ -27,8 +28,8 @@ pub fn mine(
txs: Vec<Transaction>,
activate: bool,
) {
let (block_height, _) = mine_block(rpc_client, BranchId::Nu5, txs, activate);
sync_from_height(block_height, wallet, rpc_client);
let (_, _) = mine_block(rpc_client, BranchId::Nu5, txs, activate);
sync(wallet, rpc_client);
}

/// Mine a block with the given transactions and return the block height and coinbase txid
Expand Down Expand Up @@ -107,7 +108,10 @@ pub fn create_shield_coinbase_transaction(

/// Sync the wallet with the node
pub fn sync(wallet: &mut Wallet, rpc: &mut dyn RpcClient) {
let current_height = wallet.last_block_height().map_or(0, |h| h.into());
let current_height = match wallet.last_block_height() {
None => 0,
Some(height) => height.add(1).into(),
};
sync_from_height(current_height, wallet, rpc);
}

Expand Down

0 comments on commit a4ba0f2

Please sign in to comment.