diff --git a/lib/contacts/views/contacts_browser.dart b/lib/contacts/views/contacts_browser.dart index 22c64c7..c04a4e4 100644 --- a/lib/contacts/views/contacts_browser.dart +++ b/lib/contacts/views/contacts_browser.dart @@ -83,11 +83,11 @@ class _ContactsBrowserState extends State final menuIconColor = scaleConfig.preferBorders ? scaleScheme.primaryScale.hoverBorder : scaleScheme.primaryScale.hoverBorder; - final menuBackgroundColor = scaleConfig.preferBorders - ? scaleScheme.primaryScale.activeElementBackground - : scaleScheme.primaryScale.activeElementBackground; + // final menuBackgroundColor = scaleConfig.preferBorders + // ? scaleScheme.primaryScale.activeElementBackground + // : scaleScheme.primaryScale.activeElementBackground; - final menuBorderColor = scaleScheme.primaryScale.hoverBorder; + // final menuBorderColor = scaleScheme.primaryScale.hoverBorder; PopupMenuEntry makeMenuButton( {required IconData iconData, diff --git a/packages/veilid_support/lib/dht_support/src/dht_log/dht_log.dart b/packages/veilid_support/lib/dht_support/src/dht_log/dht_log.dart index 2687bdc..20471da 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_log/dht_log.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_log/dht_log.dart @@ -211,12 +211,12 @@ class DHTLog implements DHTDeleteable { OwnedDHTRecordPointer get recordPointer => _spine.recordPointer; /// Runs a closure allowing read-only access to the log - Future operate(Future Function(DHTLogReadOperations) closure) async { + Future operate(Future Function(DHTLogReadOperations) closure) { if (!isOpen) { throw StateError('log is not open'); } - return _spine.operate((spine) async { + return _spine.operate((spine) { final reader = _DHTLogRead._(spine); return closure(reader); }); @@ -228,12 +228,12 @@ class DHTLog implements DHTDeleteable { /// Throws DHTOperateException if the write could not be performed /// at this time Future operateAppend( - Future Function(DHTLogWriteOperations) closure) async { + Future Function(DHTLogWriteOperations) closure) { if (!isOpen) { throw StateError('log is not open'); } - return _spine.operateAppend((spine) async { + return _spine.operateAppend((spine) { final writer = _DHTLogWrite._(spine); return closure(writer); }); @@ -247,12 +247,12 @@ class DHTLog implements DHTDeleteable { /// eventual consistency pass. Future operateAppendEventual( Future Function(DHTLogWriteOperations) closure, - {Duration? timeout}) async { + {Duration? timeout}) { if (!isOpen) { throw StateError('log is not open'); } - return _spine.operateAppendEventual((spine) async { + return _spine.operateAppendEventual((spine) { final writer = _DHTLogWrite._(spine); return closure(writer); }, timeout: timeout); @@ -308,7 +308,7 @@ class DHTLog implements DHTDeleteable { int _openCount; // Watch mutex to ensure we keep the representation valid - final Mutex _listenMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null); + final _listenMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null); // Stream of external changes StreamController? _watchController; } diff --git a/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_cubit.dart b/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_cubit.dart index a7884f9..3a618dc 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_cubit.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_cubit.dart @@ -106,13 +106,13 @@ class DHTLogCubit extends Cubit> await _refreshNoWait(forceRefresh: forceRefresh); } - Future _refreshNoWait({bool forceRefresh = false}) async => - busy((emit) async => _refreshInner(emit, forceRefresh: forceRefresh)); + Future _refreshNoWait({bool forceRefresh = false}) => + busy((emit) => _refreshInner(emit, forceRefresh: forceRefresh)); Future _refreshInner(void Function(AsyncValue>) emit, {bool forceRefresh = false}) async { late final int length; - final windowElements = await _log.operate((reader) async { + final windowElements = await _log.operate((reader) { length = reader.length; return _loadElementsFromReader(reader, _windowTail, _windowSize); }); @@ -237,7 +237,7 @@ class DHTLogCubit extends Cubit> late final DHTLog _log; final T Function(List data) _decodeElement; StreamSubscription? _subscription; - bool _wantsCloseRecord = false; + var _wantsCloseRecord = false; final _sspUpdate = SingleStatelessProcessor(); // Accumulated deltas since last update diff --git a/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_spine.dart b/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_spine.dart index 6323692..0aebd6c 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_spine.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_spine.dart @@ -44,6 +44,8 @@ class _SubkeyData { _SubkeyData({required this.subkey, required this.data}); int subkey; Uint8List data; + // lint conflict + // ignore: omit_obvious_property_types bool changed = false; } @@ -123,12 +125,12 @@ class _DHTLogSpine { } // Will deep delete all segment records as they are children - Future delete() async => _spineMutex.protect(_spineRecord.delete); + Future delete() => _spineMutex.protect(_spineRecord.delete); - Future operate(Future Function(_DHTLogSpine) closure) async => - _spineMutex.protect(() async => closure(this)); + Future operate(Future Function(_DHTLogSpine) closure) => + _spineMutex.protect(() => closure(this)); - Future operateAppend(Future Function(_DHTLogSpine) closure) async => + Future operateAppend(Future Function(_DHTLogSpine) closure) => _spineMutex.protect(() async { final oldHead = _head; final oldTail = _tail; @@ -150,7 +152,7 @@ class _DHTLogSpine { }); Future operateAppendEventual(Future Function(_DHTLogSpine) closure, - {Duration? timeout}) async { + {Duration? timeout}) { final timeoutTs = timeout == null ? null : Veilid.instance.now().offset(TimestampDuration.fromDuration(timeout)); @@ -264,7 +266,7 @@ class _DHTLogSpine { ///////////////////////////////////////////////////////////////////////////// // Spine element management - static final Uint8List _emptySegmentKey = + static final _emptySegmentKey = Uint8List.fromList(List.filled(TypedKey.decodedLength(), 0)); static Uint8List _makeEmptySubkey() => Uint8List.fromList(List.filled( DHTLog.segmentsPerSubkey * TypedKey.decodedLength(), 0)); @@ -420,7 +422,7 @@ class _DHTLogSpine { Future<_DHTLogPosition?> lookupPositionBySegmentNumber( int segmentNumber, int segmentPos, - {bool onlyOpened = false}) async => + {bool onlyOpened = false}) => _spineCacheMutex.protect(() async { // See if we have this segment opened already final openedSegment = _openedSegments[segmentNumber]; @@ -468,7 +470,7 @@ class _DHTLogSpine { segmentNumber: segmentNumber); }); - Future<_DHTLogPosition?> lookupPosition(int pos) async { + Future<_DHTLogPosition?> lookupPosition(int pos) { assert(_spineMutex.isLocked, 'should be locked'); // Check if our position is in bounds @@ -487,7 +489,7 @@ class _DHTLogSpine { return lookupPositionBySegmentNumber(segmentNumber, segmentPos); } - Future _segmentClosed(int segmentNumber) async { + Future _segmentClosed(int segmentNumber) { assert(_spineMutex.isLocked, 'should be locked'); return _spineCacheMutex.protect(() async { final sa = _openedSegments[segmentNumber]!; @@ -709,7 +711,7 @@ class _DHTLogSpine { DHTShortArray.maxElements; // Spine head mutex to ensure we keep the representation valid - final Mutex _spineMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null); + final _spineMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null); // Subscription to head record internal changes StreamSubscription? _subscription; // Notify closure for external spine head changes @@ -729,9 +731,8 @@ class _DHTLogSpine { // LRU cache of DHT spine elements accessed recently // Pair of position and associated shortarray segment - final Mutex _spineCacheMutex = - Mutex(debugLockTimeout: kIsDebugMode ? 60 : null); + final _spineCacheMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null); final List _openCache; final Map _openedSegments; - static const int _openCacheSize = 3; + static const _openCacheSize = 3; } diff --git a/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_write.dart b/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_write.dart index 397a1dc..00eaa94 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_write.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_log/dht_log_write.dart @@ -60,7 +60,7 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations { if (aLookup.shortArray == bLookup.shortArray) { await bLookup.close(); return aLookup.scope((sa) => sa.operateWriteEventual( - (aWrite) async => aWrite.swap(aLookup.pos, bLookup.pos))); + (aWrite) => aWrite.swap(aLookup.pos, bLookup.pos))); } else { final bItem = Output(); return aLookup.scope( @@ -101,7 +101,7 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations { } // Write item to the segment - return lookup.scope((sa) async => sa.operateWrite((write) async { + return lookup.scope((sa) => sa.operateWrite((write) async { // If this a new segment, then clear it in case we have wrapped around if (lookup.pos == 0) { await write.clear(); @@ -140,7 +140,7 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations { dws.add((_) async { try { - await lookup.scope((sa) async => sa.operateWrite((write) async { + await lookup.scope((sa) => sa.operateWrite((write) async { // If this a new segment, then clear it in // case we have wrapped around if (lookup.pos == 0) { diff --git a/packages/veilid_support/lib/dht_support/src/dht_record/dht_record.dart b/packages/veilid_support/lib/dht_support/src/dht_record/dht_record.dart index b9218e4..893cb80 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_record/dht_record.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_record/dht_record.dart @@ -92,7 +92,7 @@ class DHTRecord implements DHTDeleteable { /// Returns true if the deletion was processed immediately /// Returns false if the deletion was marked for later @override - Future delete() async => DHTRecordPool.instance.deleteRecord(key); + Future delete() => DHTRecordPool.instance.deleteRecord(key); //////////////////////////////////////////////////////////////////////////// // Public API @@ -122,7 +122,7 @@ class DHTRecord implements DHTDeleteable { {int subkey = -1, VeilidCrypto? crypto, DHTRecordRefreshMode refreshMode = DHTRecordRefreshMode.cached, - Output? outSeqNum}) async => + Output? outSeqNum}) => _wrapStats('get', () async { subkey = subkeyOrDefault(subkey); @@ -227,7 +227,7 @@ class DHTRecord implements DHTDeleteable { {int subkey = -1, VeilidCrypto? crypto, KeyPair? writer, - Output? outSeqNum}) async => + Output? outSeqNum}) => _wrapStats('tryWriteBytes', () async { subkey = subkeyOrDefault(subkey); final lastSeq = await _localSubkeySeq(subkey); @@ -238,8 +238,8 @@ class DHTRecord implements DHTDeleteable { key, subkey, encryptedNewValue, writer: writer ?? _writer); if (newValueData == null) { - // A newer value wasn't found on the set, but - // we may get a newer value when getting the value for the sequence number + // A newer value wasn't found on the set, but we may get a newer value + // when getting the value for the sequence number newValueData = await _routingContext.getDHTValue(key, subkey); if (newValueData == null) { assert(newValueData != null, "can't get value that was just set"); @@ -280,7 +280,7 @@ class DHTRecord implements DHTDeleteable { {int subkey = -1, VeilidCrypto? crypto, KeyPair? writer, - Output? outSeqNum}) async => + Output? outSeqNum}) => _wrapStats('eventualWriteBytes', () async { subkey = subkeyOrDefault(subkey); final lastSeq = await _localSubkeySeq(subkey); @@ -331,7 +331,7 @@ class DHTRecord implements DHTDeleteable { {int subkey = -1, VeilidCrypto? crypto, KeyPair? writer, - Output? outSeqNum}) async => + Output? outSeqNum}) => _wrapStats('eventualUpdateBytes', () async { subkey = subkeyOrDefault(subkey); diff --git a/packages/veilid_support/lib/dht_support/src/dht_record/dht_record_pool.dart b/packages/veilid_support/lib/dht_support/src/dht_record/dht_record_pool.dart index 6dc0634..cfa123d 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_record/dht_record_pool.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_record/dht_record_pool.dart @@ -20,13 +20,13 @@ part 'dht_record.dart'; part 'dht_record_pool_private.dart'; /// Maximum number of concurrent DHT operations to perform on the network -const int kMaxDHTConcurrency = 8; +const kMaxDHTConcurrency = 8; /// Total number of times to try in a 'VeilidAPIExceptionKeyNotFound' loop -const int kDHTKeyNotFoundTries = 3; +const kDHTKeyNotFoundTries = 3; /// Total number of times to try in a 'VeilidAPIExceptionTryAgain' loop -const int kDHTTryAgainTries = 3; +const kDHTTryAgainTries = 3; typedef DHTRecordPoolLogger = void Function(String message); @@ -105,7 +105,7 @@ class DHTRecordPool with TableDBBackedJson { int defaultSubkey = 0, VeilidCrypto? crypto, KeyPair? writer, - }) async => + }) => _mutex.protect(() async { final dhtctx = routingContext ?? _routingContext; @@ -139,7 +139,7 @@ class DHTRecordPool with TableDBBackedJson { VeilidRoutingContext? routingContext, TypedKey? parent, int defaultSubkey = 0, - VeilidCrypto? crypto}) async => + VeilidCrypto? crypto}) => _recordTagLock.protect(recordKey, closure: () async { final dhtctx = routingContext ?? _routingContext; @@ -164,7 +164,7 @@ class DHTRecordPool with TableDBBackedJson { TypedKey? parent, int defaultSubkey = 0, VeilidCrypto? crypto, - }) async => + }) => _recordTagLock.protect(recordKey, closure: () async { final dhtctx = routingContext ?? _routingContext; @@ -223,8 +223,8 @@ class DHTRecordPool with TableDBBackedJson { /// otherwise mark that record for deletion eventually /// Returns true if the deletion was processed immediately /// Returns false if the deletion was marked for later - Future deleteRecord(TypedKey recordKey) async => - _mutex.protect(() async => _deleteRecordInner(recordKey)); + Future deleteRecord(TypedKey recordKey) => + _mutex.protect(() => _deleteRecordInner(recordKey)); // If everything underneath is closed including itself, return the // list of children (and itself) to finally actually delete @@ -314,7 +314,7 @@ class DHTRecordPool with TableDBBackedJson { /// Generate default VeilidCrypto for a writer static Future privateCryptoFromTypedSecret( - TypedKey typedSecret) async => + TypedKey typedSecret) => VeilidCryptoPrivate.fromTypedKey(typedSecret, _cryptoDomainDHT); //////////////////////////////////////////////////////////////////////////// @@ -362,7 +362,7 @@ class DHTRecordPool with TableDBBackedJson { required VeilidCrypto crypto, required KeyPair? writer, required TypedKey? parent, - required int defaultSubkey}) async => + required int defaultSubkey}) => _stats.measure(recordKey, debugName, '_recordOpenCommon', () async { log('openDHTRecord: debugName=$debugName key=$recordKey'); @@ -428,8 +428,8 @@ class DHTRecordPool with TableDBBackedJson { // Already opened - // See if we need to reopen the record with a default writer and possibly - // a different routing context + // See if we need to reopen the record with a default writer and + // possibly a different routing context if (writer != null && openedRecordInfo.shared.defaultWriter == null) { await dhtctx.openDHTRecord(recordKey, writer: writer); // New writer if we didn't specify one before @@ -889,7 +889,7 @@ class DHTRecordPool with TableDBBackedJson { } /// Ticker to check watch state change requests - Future tick() async => _mutex.protect(() async { + Future tick() => _mutex.protect(() async { // See if any opened records need watch state changes for (final kv in _opened.entries) { final openedRecordKey = kv.key; diff --git a/packages/veilid_support/lib/dht_support/src/dht_record/dht_record_pool_private.dart b/packages/veilid_support/lib/dht_support/src/dht_record/dht_record_pool_private.dart index 05b93b0..2474c87 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_record/dht_record_pool_private.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_record/dht_record_pool_private.dart @@ -1,7 +1,7 @@ part of 'dht_record_pool.dart'; // DHT crypto domain -const String _cryptoDomainDHT = 'dht'; +const _cryptoDomainDHT = 'dht'; // Singlefuture keys const _sfPollWatch = '_pollWatch'; @@ -32,6 +32,8 @@ class _SharedDHTRecordData { DHTRecordDescriptor recordDescriptor; KeyPair? defaultWriter; VeilidRoutingContext defaultRoutingContext; + // lint conflict + // ignore: omit_obvious_property_types bool needsWatchStateUpdate = false; _WatchState? unionWatchState; } diff --git a/packages/veilid_support/lib/dht_support/src/dht_record/stats.dart b/packages/veilid_support/lib/dht_support/src/dht_record/stats.dart index 6388f5c..22b517b 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_record/stats.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_record/stats.dart @@ -80,7 +80,12 @@ class DHTCallStats { ' all latency: ${latency?.debugString()}\n'; ///////////////////////////// + + // lint conflict + // ignore: omit_obvious_property_types int calls = 0; + // lint conflict + // ignore: omit_obvious_property_types int timeouts = 0; LatencyStats? latency; LatencyStats? successLatency; diff --git a/packages/veilid_support/lib/dht_support/src/dht_short_array/dht_short_array.dart b/packages/veilid_support/lib/dht_support/src/dht_short_array/dht_short_array.dart index ccf7d18..4a03cd9 100644 --- a/packages/veilid_support/lib/dht_support/src/dht_short_array/dht_short_array.dart +++ b/packages/veilid_support/lib/dht_support/src/dht_short_array/dht_short_array.dart @@ -174,7 +174,7 @@ class DHTShortArray implements DHTDeleteable { /// Returns true if the deletion was processed immediately /// Returns false if the deletion was marked for later @override - Future delete() async => _head.delete(); + Future delete() => _head.delete(); //////////////////////////////////////////////////////////////////////////// // Public API @@ -201,12 +201,12 @@ class DHTShortArray implements DHTDeleteable { /// Runs a closure allowing read-only access to the shortarray Future operate( - Future Function(DHTShortArrayReadOperations) closure) async { + Future Function(DHTShortArrayReadOperations) closure) { if (!isOpen) { throw StateError('short array is not open"'); } - return _head.operate((head) async { + return _head.operate((head) { final reader = _DHTShortArrayRead._(head); return closure(reader); }); @@ -218,12 +218,12 @@ class DHTShortArray implements DHTDeleteable { /// Throws DHTOperateException if the write could not be performed /// at this time Future operateWrite( - Future Function(DHTShortArrayWriteOperations) closure) async { + Future Function(DHTShortArrayWriteOperations) closure) { if (!isOpen) { throw StateError('short array is not open"'); } - return _head.operateWrite((head) async { + return _head.operateWrite((head) { final writer = _DHTShortArrayWrite._(head); return closure(writer); }); @@ -237,12 +237,12 @@ class DHTShortArray implements DHTDeleteable { /// eventual consistency pass. Future operateWriteEventual( Future Function(DHTShortArrayWriteOperations) closure, - {Duration? timeout}) async { + {Duration? timeout}) { if (!isOpen) { throw StateError('short array is not open"'); } - return _head.operateWriteEventual((head) async { + return _head.operateWriteEventual((head) { final writer = _DHTShortArrayWrite._(head); return closure(writer); }, timeout: timeout); @@ -291,7 +291,7 @@ class DHTShortArray implements DHTDeleteable { int _openCount; // Watch mutex to ensure we keep the representation valid - final Mutex _listenMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null); + final _listenMutex = Mutex(debugLockTimeout: kIsDebugMode ? 60 : null); // Stream of external changes StreamController? _watchController; } diff --git a/packages/veilid_support/lib/dht_support/src/interfaces/dht_closeable.dart b/packages/veilid_support/lib/dht_support/src/interfaces/dht_closeable.dart index 0fb10ab..bda4afb 100644 --- a/packages/veilid_support/lib/dht_support/src/interfaces/dht_closeable.dart +++ b/packages/veilid_support/lib/dht_support/src/interfaces/dht_closeable.dart @@ -56,7 +56,7 @@ extension DHTDeletableExt on DHTDeleteable { /// Scopes a closure that conditionally deletes the DHTCloseable on exit Future maybeDeleteScope( - bool delete, Future Function(D) scopeFunction) async { + bool delete, Future Function(D) scopeFunction) { if (delete) { return deleteScope(scopeFunction); } diff --git a/packages/veilid_support/lib/dht_support/src/interfaces/refreshable_cubit.dart b/packages/veilid_support/lib/dht_support/src/interfaces/refreshable_cubit.dart index a04e1bb..d987b38 100644 --- a/packages/veilid_support/lib/dht_support/src/interfaces/refreshable_cubit.dart +++ b/packages/veilid_support/lib/dht_support/src/interfaces/refreshable_cubit.dart @@ -12,5 +12,5 @@ abstract mixin class RefreshableCubit { bool get wantsRefresh => _wantsRefresh; //////////////////////////////////////////////////////////////////////////// - bool _wantsRefresh = false; + var _wantsRefresh = false; }