Skip to content

Commit

Permalink
Cleanup sync options for single address
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Nov 6, 2023
1 parent e66635b commit 56f5cd3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
22 changes: 0 additions & 22 deletions sdk/src/wallet/operations/syncing/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

use serde::{Deserialize, Serialize};

use crate::types::block::address::Bech32Address;

const DEFAULT_ADDRESS_START_INDEX: u32 = 0;
const DEFAULT_FORCE_SYNCING: bool = false;
const DEFAULT_SYNC_INCOMING_TRANSACTIONS: bool = false;
const DEFAULT_SYNC_ONLY_MOST_BASIC_OUTPUTS: bool = false;
Expand All @@ -16,18 +13,6 @@ const DEFAULT_SYNC_NATIVE_TOKEN_FOUNDRIES: bool = false;
#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SyncOptions {
/// Specific Bech32 encoded addresses of the account to sync, if addresses are provided, then `address_start_index`
/// will be ignored
#[serde(default)]
pub addresses: Vec<Bech32Address>,
/// Address index from which to start syncing addresses. 0 by default, using a higher index will be faster because
/// addresses with a lower index will be skipped, but could result in a wrong balance for that reason
#[serde(default = "default_address_start_index")]
pub address_start_index: u32,
/// Address index from which to start syncing internal addresses. 0 by default, using a higher index will be faster
/// because addresses with a lower index will be skipped, but could result in a wrong balance for that reason
#[serde(default = "default_address_start_index")]
pub address_start_index_internal: u32,
/// Usually syncing is skipped if it's called in between 200ms, because there can only be new changes every
/// milestone and calling it twice "at the same time" will not return new data
/// When this to true, we will sync anyways, even if it's called 0ms after the las sync finished.
Expand Down Expand Up @@ -58,10 +43,6 @@ pub struct SyncOptions {
pub sync_native_token_foundries: bool,
}

fn default_address_start_index() -> u32 {
DEFAULT_ADDRESS_START_INDEX
}

fn default_force_syncing() -> bool {
DEFAULT_FORCE_SYNCING
}
Expand All @@ -85,9 +66,6 @@ fn default_sync_native_token_foundries() -> bool {
impl Default for SyncOptions {
fn default() -> Self {
Self {
addresses: Vec::new(),
address_start_index: default_address_start_index(),
address_start_index_internal: default_address_start_index(),
sync_incoming_transactions: default_sync_incoming_transactions(),
sync_pending_transactions: default_sync_pending_transactions(),
wallet: WalletSyncOptions::default(),
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/wallet/syncing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// assert_eq!(default_sync, wallet.default_sync_options().await);

// let custom_options = SyncOptions {
// address_start_index: 10,
// sync_only_most_basic_outputs: true,
// ..Default::default()
// };
// wallet.set_default_sync_options(custom_options.clone()).await?;
Expand Down

0 comments on commit 56f5cd3

Please sign in to comment.