Skip to content

Commit

Permalink
take 14 days back from birthday to account for reorgs
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeantonio21 committed Nov 15, 2022
1 parent 249ebf1 commit 763e243
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,9 @@ where
client: &mut BaseNodeWalletRpcClient,
) -> Result<HeightHash, UtxoScannerError> {
let birthday = self.resources.db.get_wallet_birthday()?;
// Calculate the unix epoch time of two days before the wallet birthday.
// Calculate the unix epoch time of two weeks (14 days) before the wallet birthday.
// This is to avoid any weird time zone issues
let epoch_time = get_birthday_from_unix_epoch(birthday, 2u16);
let epoch_time = get_birthday_from_unix_epoch(birthday, 14u16);

let block_height = match client.get_height_at_time(epoch_time).await {
Ok(b) => b,
Expand Down
10 changes: 5 additions & 5 deletions base_layer/wallet/tests/utxo_scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ async fn test_utxo_scanner_recovery() {
let mut test_interface = setup(UtxoScannerMode::Recovery, None, None, None).await;

let cipher_seed = CipherSeed::new();
let birthday_epoch_time = get_birthday_from_unix_epoch(cipher_seed.birthday(), 2u16);
let birthday_epoch_time = get_birthday_from_unix_epoch(cipher_seed.birthday(), 14u16);
test_interface.wallet_db.set_master_seed(cipher_seed).unwrap();

const NUM_BLOCKS: u64 = 11;
Expand Down Expand Up @@ -369,7 +369,7 @@ async fn test_utxo_scanner_recovery_with_restart() {
let mut test_interface = setup(UtxoScannerMode::Recovery, None, None, None).await;

let cipher_seed = CipherSeed::new();
let birthday_epoch_time = get_birthday_from_unix_epoch(cipher_seed.birthday(), 2);
let birthday_epoch_time = get_birthday_from_unix_epoch(cipher_seed.birthday(), 14);
test_interface.wallet_db.set_master_seed(cipher_seed).unwrap();

test_interface
Expand Down Expand Up @@ -533,7 +533,7 @@ async fn test_utxo_scanner_recovery_with_restart_and_reorg() {
let mut test_interface = setup(UtxoScannerMode::Recovery, None, None, None).await;

let cipher_seed = CipherSeed::new();
let birthday_epoch_time = get_birthday_from_unix_epoch(cipher_seed.birthday(), 2);
let birthday_epoch_time = get_birthday_from_unix_epoch(cipher_seed.birthday(), 14);
test_interface.wallet_db.set_master_seed(cipher_seed).unwrap();

const NUM_BLOCKS: u64 = 11;
Expand Down Expand Up @@ -702,7 +702,7 @@ async fn test_utxo_scanner_scanned_block_cache_clearing() {
}

let cipher_seed = CipherSeed::new();
let birthday_epoch_time = get_birthday_from_unix_epoch(cipher_seed.birthday(), 2);
let birthday_epoch_time = get_birthday_from_unix_epoch(cipher_seed.birthday(), 14);
test_interface.wallet_db.set_master_seed(cipher_seed).unwrap();

const NUM_BLOCKS: u64 = 11;
Expand Down Expand Up @@ -804,7 +804,7 @@ async fn test_utxo_scanner_one_sided_payments() {
.await;

let cipher_seed = CipherSeed::new();
let birthday_epoch_time = get_birthday_from_unix_epoch(cipher_seed.birthday(), 2u16);
let birthday_epoch_time = get_birthday_from_unix_epoch(cipher_seed.birthday(), 14u16);
test_interface.wallet_db.set_master_seed(cipher_seed).unwrap();

const NUM_BLOCKS: u64 = 11;
Expand Down

0 comments on commit 763e243

Please sign in to comment.