simplify config and fix refresh

This commit is contained in:
Christien Rioux 2024-03-05 15:29:02 -05:00
parent c9e0831555
commit d3cdca17c5
4 changed files with 23 additions and 34 deletions

View File

@ -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;
}

View File

@ -569,7 +569,7 @@ class DHTRecordPool with TableDBBacked<DHTRecordPoolAllocations> {
subkeys: allSubkeys, expiration: maxExpiration, count: totalCount);
}
void _updateWatchExpirations(
void _updateWatchRealExpirations(
Iterable<DHTRecord> records, Timestamp realExpiration) {
for (final rec in records) {
final ws = rec.watchState;
@ -636,7 +636,7 @@ class DHTRecordPool with TableDBBacked<DHTRecordPoolAllocations> {
// Update watch states with real expiration
if (realExpiration.value != BigInt.zero) {
openedRecordInfo.shared.needsWatchStateUpdate = false;
_updateWatchExpirations(
_updateWatchRealExpirations(
openedRecordInfo.records, realExpiration);
success = true;
}

View File

@ -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

View File

@ -1,4 +1,5 @@
import 'package:veilid/veilid.dart';
import 'dart:io' show Platform;
Map<String, dynamic> getDefaultVeilidPlatformConfig(
bool isWeb, String appName) {
@ -43,8 +44,18 @@ Map<String, dynamic> getDefaultVeilidPlatformConfig(
.toJson();
}
Future<VeilidConfig> getVeilidConfig(bool isWeb, String appName) async {
var config = await getDefaultVeilidConfig(appName);
Future<VeilidConfig> 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<VeilidConfig> 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),
);
}