Skip to content

Commit

Permalink
Cleanup sync options for single address (#1581)
Browse files Browse the repository at this point in the history
* Cleanup sync options for single address

* Update bindings
  • Loading branch information
Thoralf-M authored Nov 6, 2023
1 parent e66635b commit a1715d4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 54 deletions.
16 changes: 0 additions & 16 deletions bindings/nodejs/lib/types/wallet/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { OutputData } from './output';
import type { TransactionWithMetadata } from './transaction';
import { CoinType } from '../../client';
import { HexEncodedString, u256, u64 } from '../utils';
import { Bech32Address } from '../block/address';

/**
* Account identifier
Expand Down Expand Up @@ -72,21 +71,6 @@ export interface NativeTokenBalance {

/** Sync options for an account */
export interface SyncOptions {
/**
* Specific Bech32 encoded addresses of the account to sync, if addresses are provided,
* then `address_start_index` will be ignored
*/
addresses?: 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
*/
addressStartIndex?: number;
/**
* 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
*/
addressStartIndexInternal?: number;
/**
* 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
Expand Down
16 changes: 1 addition & 15 deletions bindings/python/iota_sdk/wallet/sync_options.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2023 IOTA Stiftung
# SPDX-License-Identifier: Apache-2.0

from typing import List, Optional
from typing import Optional
from dataclasses import dataclass
from iota_sdk.types.common import json

Expand Down Expand Up @@ -62,17 +62,6 @@ class SyncOptions():
"""The synchronization options.
**Attributes**
addresses :
Specific Bech32 encoded addresses of the account to sync. If addresses are provided,
then `address_start_index` will be ignored.
address_start_index :
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 this could result in a wrong balance for that reason.
address_start_index_internal :
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 this could result in a wrong balance for internal addresses for that reason.
force_syncing :
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.
Expand All @@ -96,9 +85,6 @@ class SyncOptions():
Sync native token foundries, so their metadata can be returned in the balance.
"""

addresses: Optional[List[str]] = None
address_start_index: Optional[int] = None
address_start_index_internal: Optional[int] = None
force_syncing: Optional[bool] = None
sync_incoming_transactions: Optional[bool] = None
sync_pending_transactions: Optional[bool] = None
Expand Down
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 a1715d4

Please sign in to comment.