diff --git a/lib/account_manager/repository/account_repository/account_repository.dart b/lib/account_manager/repository/account_repository/account_repository.dart index 1b145b3..39b1261 100644 --- a/lib/account_manager/repository/account_repository/account_repository.dart +++ b/lib/account_manager/repository/account_repository/account_repository.dart @@ -343,13 +343,14 @@ class AccountRepository { await _userLogins.set(newUserLogins); await _activeLocalAccount.set(identityMaster.masterRecordKey); - _streamController - ..add(AccountRepositoryChange.userLogins) - ..add(AccountRepositoryChange.activeLocalAccount); // Ensure all logins are opened await _openLoggedInDHTRecords(); + _streamController + ..add(AccountRepositoryChange.userLogins) + ..add(AccountRepositoryChange.activeLocalAccount); + return true; } diff --git a/packages/veilid_support/lib/dht_support/src/dht_record_pool.dart b/packages/veilid_support/lib/dht_support/src/dht_record_pool.dart index 7389123..80d1d43 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_record_pool.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_record_pool.dart @@ -569,7 +569,7 @@ class DHTRecordPool with TableDBBacked { subkeys: allSubkeys, expiration: maxExpiration, count: totalCount); } - void _updateWatchExpirations( + void _updateWatchRealExpirations( Iterable records, Timestamp realExpiration) { for (final rec in records) { final ws = rec.watchState; @@ -636,7 +636,7 @@ class DHTRecordPool with TableDBBacked { // Update watch states with real expiration if (realExpiration.value != BigInt.zero) { openedRecordInfo.shared.needsWatchStateUpdate = false; - _updateWatchExpirations( + _updateWatchRealExpirations( openedRecordInfo.records, realExpiration); success = true; } diff --git a/packages/veilid_support/lib/dht_support/src/dht_short_array.dart b/packages/veilid_support/lib/dht_support/src/dht_short_array.dart index 8cc0e37..3de5df5 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_short_array.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_short_array.dart @@ -759,7 +759,7 @@ class DHTShortArray { for (final skr in subkeys) { for (var subkey = skr.low; subkey <= skr.high; subkey++) { // Skip head subkey - if (subkey == 0) { + if (updateHead && subkey == 0) { continue; } // Get the subkey, which caches the result in the local record store diff --git a/packages/veilid_support/lib/src/config.dart b/packages/veilid_support/lib/src/config.dart index dff9f3e..c13a8b8 100644 --- a/packages/veilid_support/lib/src/config.dart +++ b/packages/veilid_support/lib/src/config.dart @@ -1,4 +1,5 @@ import 'package:veilid/veilid.dart'; +import 'dart:io' show Platform; Map getDefaultVeilidPlatformConfig( bool isWeb, String appName) { @@ -43,8 +44,18 @@ Map getDefaultVeilidPlatformConfig( .toJson(); } -Future getVeilidConfig(bool isWeb, String appName) async { - var config = await getDefaultVeilidConfig(appName); +Future getVeilidConfig(bool isWeb, String programName) async { + var config = await getDefaultVeilidConfig( + isWeb: isWeb, + programName: programName, + // ignore: avoid_redundant_argument_values, do_not_use_environment + namespace: const String.fromEnvironment('NAMESPACE'), + // ignore: avoid_redundant_argument_values, do_not_use_environment + bootstrap: const String.fromEnvironment('BOOTSTRAP'), + // ignore: avoid_redundant_argument_values, do_not_use_environment + networkKeyPassword: const String.fromEnvironment('NETWORK_KEY'), + ); + // ignore: do_not_use_environment if (const String.fromEnvironment('DELETE_TABLE_STORE') == '1') { config = @@ -73,35 +84,12 @@ Future getVeilidConfig(bool isWeb, String appName) async { config.network.routingTable.copyWith(bootstrap: bootstrap))); } - // ignore: do_not_use_environment - const envNetworkKey = String.fromEnvironment('NETWORK_KEY'); - if (envNetworkKey.isNotEmpty) { - config = config.copyWith( - network: config.network.copyWith(networkKeyPassword: envNetworkKey)); - } - - // ignore: do_not_use_environment - const envBootstrap = String.fromEnvironment('BOOTSTRAP'); - if (envBootstrap.isNotEmpty) { - final bootstrap = envBootstrap.split(',').map((e) => e.trim()).toList(); - config = config.copyWith( - network: config.network.copyWith( - routingTable: - config.network.routingTable.copyWith(bootstrap: bootstrap))); - } - return config.copyWith( capabilities: // XXX: Remove DHTV and DHTW when we get background sync implemented const VeilidConfigCapabilities(disable: ['DHTV', 'DHTW', 'TUNL']), - protectedStore: config.protectedStore.copyWith(allowInsecureFallback: true), - // network: config.network.copyWith( - // dht: config.network.dht.copyWith( - // getValueCount: 3, - // getValueFanout: 8, - // getValueTimeoutMs: 5000, - // setValueCount: 4, - // setValueFanout: 10, - // setValueTimeoutMs: 5000)) + protectedStore: + // XXX: Linux often does not have a secret storage mechanism installed + config.protectedStore.copyWith(allowInsecureFallback: Platform.isLinux), ); }