reload method

void reload (
  1. {bool initialLoad: false}
)

Fully re-synchronize with the PeerNetwork.

Implementation

void reload({bool initialLoad = false}) async {
  if (!opened && !initialLoad) return;
  debugPrint((initialLoad ? 'Load' : 'Reload') + ' wallet ' + name);
  opened = true;
  pendingCount = 0;
  transactions.clear();

  List<Address> reloadAddresses = addresses.values.toList();
  List<Future<void>> reloading = List<Future<void>>(reloadAddresses.length);
  for (int i = 0; i < reloadAddresses.length; i++) {
    reloading[i] = _filterNetworkFor(reloadAddresses[i]);
  }
  for (int i = 0; i < reloadAddresses.length; i++) {
    await reloading[i];
  }

  if (network.hasPeer) {
    await (await network.getPeer()).filterTransactionQueue();
  }

  /// Read pending transations last, so we know if they've already been
  /// applied to our balance.
  await _readPendingTransactions(network.tipHeight ?? 0);
}