fix lints

This commit is contained in:
Christien Rioux 2025-06-02 15:47:37 -04:00
parent 2f597ef1a2
commit aeaf34e55d
12 changed files with 70 additions and 62 deletions

View file

@ -83,11 +83,11 @@ class _ContactsBrowserState extends State<ContactsBrowser>
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<void> makeMenuButton(
{required IconData iconData,

View file

@ -211,12 +211,12 @@ class DHTLog implements DHTDeleteable<DHTLog> {
OwnedDHTRecordPointer get recordPointer => _spine.recordPointer;
/// Runs a closure allowing read-only access to the log
Future<T> operate<T>(Future<T> Function(DHTLogReadOperations) closure) async {
Future<T> operate<T>(Future<T> 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<DHTLog> {
/// Throws DHTOperateException if the write could not be performed
/// at this time
Future<T> operateAppend<T>(
Future<T> Function(DHTLogWriteOperations) closure) async {
Future<T> 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<DHTLog> {
/// eventual consistency pass.
Future<T> operateAppendEventual<T>(
Future<T> 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<DHTLog> {
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<DHTLogUpdate>? _watchController;
}

View file

@ -106,13 +106,13 @@ class DHTLogCubit<T> extends Cubit<DHTLogBusyState<T>>
await _refreshNoWait(forceRefresh: forceRefresh);
}
Future<void> _refreshNoWait({bool forceRefresh = false}) async =>
busy((emit) async => _refreshInner(emit, forceRefresh: forceRefresh));
Future<void> _refreshNoWait({bool forceRefresh = false}) =>
busy((emit) => _refreshInner(emit, forceRefresh: forceRefresh));
Future<void> _refreshInner(void Function(AsyncValue<DHTLogStateData<T>>) 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<T> extends Cubit<DHTLogBusyState<T>>
late final DHTLog _log;
final T Function(List<int> data) _decodeElement;
StreamSubscription<void>? _subscription;
bool _wantsCloseRecord = false;
var _wantsCloseRecord = false;
final _sspUpdate = SingleStatelessProcessor();
// Accumulated deltas since last update

View file

@ -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<bool> delete() async => _spineMutex.protect(_spineRecord.delete);
Future<bool> delete() => _spineMutex.protect(_spineRecord.delete);
Future<T> operate<T>(Future<T> Function(_DHTLogSpine) closure) async =>
_spineMutex.protect(() async => closure(this));
Future<T> operate<T>(Future<T> Function(_DHTLogSpine) closure) =>
_spineMutex.protect(() => closure(this));
Future<T> operateAppend<T>(Future<T> Function(_DHTLogSpine) closure) async =>
Future<T> operateAppend<T>(Future<T> Function(_DHTLogSpine) closure) =>
_spineMutex.protect(() async {
final oldHead = _head;
final oldTail = _tail;
@ -150,7 +152,7 @@ class _DHTLogSpine {
});
Future<T> operateAppendEventual<T>(Future<T> 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<TypedKey>(), 0));
static Uint8List _makeEmptySubkey() => Uint8List.fromList(List.filled(
DHTLog.segmentsPerSubkey * TypedKey.decodedLength<TypedKey>(), 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<bool> _segmentClosed(int segmentNumber) async {
Future<bool> _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<DHTRecordWatchChange>? _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<int> _openCache;
final Map<int, DHTShortArray> _openedSegments;
static const int _openCacheSize = 3;
static const _openCacheSize = 3;
}

View file

@ -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<Uint8List>();
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) {

View file

@ -92,7 +92,7 @@ class DHTRecord implements DHTDeleteable<DHTRecord> {
/// Returns true if the deletion was processed immediately
/// Returns false if the deletion was marked for later
@override
Future<bool> delete() async => DHTRecordPool.instance.deleteRecord(key);
Future<bool> delete() => DHTRecordPool.instance.deleteRecord(key);
////////////////////////////////////////////////////////////////////////////
// Public API
@ -122,7 +122,7 @@ class DHTRecord implements DHTDeleteable<DHTRecord> {
{int subkey = -1,
VeilidCrypto? crypto,
DHTRecordRefreshMode refreshMode = DHTRecordRefreshMode.cached,
Output<int>? outSeqNum}) async =>
Output<int>? outSeqNum}) =>
_wrapStats('get', () async {
subkey = subkeyOrDefault(subkey);
@ -227,7 +227,7 @@ class DHTRecord implements DHTDeleteable<DHTRecord> {
{int subkey = -1,
VeilidCrypto? crypto,
KeyPair? writer,
Output<int>? outSeqNum}) async =>
Output<int>? outSeqNum}) =>
_wrapStats('tryWriteBytes', () async {
subkey = subkeyOrDefault(subkey);
final lastSeq = await _localSubkeySeq(subkey);
@ -238,8 +238,8 @@ class DHTRecord implements DHTDeleteable<DHTRecord> {
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<DHTRecord> {
{int subkey = -1,
VeilidCrypto? crypto,
KeyPair? writer,
Output<int>? outSeqNum}) async =>
Output<int>? outSeqNum}) =>
_wrapStats('eventualWriteBytes', () async {
subkey = subkeyOrDefault(subkey);
final lastSeq = await _localSubkeySeq(subkey);
@ -331,7 +331,7 @@ class DHTRecord implements DHTDeleteable<DHTRecord> {
{int subkey = -1,
VeilidCrypto? crypto,
KeyPair? writer,
Output<int>? outSeqNum}) async =>
Output<int>? outSeqNum}) =>
_wrapStats('eventualUpdateBytes', () async {
subkey = subkeyOrDefault(subkey);

View file

@ -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<DHTRecordPoolAllocations> {
int defaultSubkey = 0,
VeilidCrypto? crypto,
KeyPair? writer,
}) async =>
}) =>
_mutex.protect(() async {
final dhtctx = routingContext ?? _routingContext;
@ -139,7 +139,7 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
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<DHTRecordPoolAllocations> {
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<DHTRecordPoolAllocations> {
/// 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<bool> deleteRecord(TypedKey recordKey) async =>
_mutex.protect(() async => _deleteRecordInner(recordKey));
Future<bool> 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<DHTRecordPoolAllocations> {
/// Generate default VeilidCrypto for a writer
static Future<VeilidCrypto> privateCryptoFromTypedSecret(
TypedKey typedSecret) async =>
TypedKey typedSecret) =>
VeilidCryptoPrivate.fromTypedKey(typedSecret, _cryptoDomainDHT);
////////////////////////////////////////////////////////////////////////////
@ -362,7 +362,7 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
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<DHTRecordPoolAllocations> {
// 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<DHTRecordPoolAllocations> {
}
/// Ticker to check watch state change requests
Future<void> tick() async => _mutex.protect(() async {
Future<void> tick() => _mutex.protect(() async {
// See if any opened records need watch state changes
for (final kv in _opened.entries) {
final openedRecordKey = kv.key;

View file

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

View file

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

View file

@ -174,7 +174,7 @@ class DHTShortArray implements DHTDeleteable<DHTShortArray> {
/// Returns true if the deletion was processed immediately
/// Returns false if the deletion was marked for later
@override
Future<bool> delete() async => _head.delete();
Future<bool> delete() => _head.delete();
////////////////////////////////////////////////////////////////////////////
// Public API
@ -201,12 +201,12 @@ class DHTShortArray implements DHTDeleteable<DHTShortArray> {
/// Runs a closure allowing read-only access to the shortarray
Future<T> operate<T>(
Future<T> Function(DHTShortArrayReadOperations) closure) async {
Future<T> 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<DHTShortArray> {
/// Throws DHTOperateException if the write could not be performed
/// at this time
Future<T> operateWrite<T>(
Future<T> Function(DHTShortArrayWriteOperations) closure) async {
Future<T> 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<DHTShortArray> {
/// eventual consistency pass.
Future<T> operateWriteEventual<T>(
Future<T> 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<DHTShortArray> {
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<void>? _watchController;
}

View file

@ -56,7 +56,7 @@ extension DHTDeletableExt<D> on DHTDeleteable<D> {
/// Scopes a closure that conditionally deletes the DHTCloseable on exit
Future<T> maybeDeleteScope<T>(
bool delete, Future<T> Function(D) scopeFunction) async {
bool delete, Future<T> Function(D) scopeFunction) {
if (delete) {
return deleteScope(scopeFunction);
}

View file

@ -12,5 +12,5 @@ abstract mixin class RefreshableCubit {
bool get wantsRefresh => _wantsRefresh;
////////////////////////////////////////////////////////////////////////////
bool _wantsRefresh = false;
var _wantsRefresh = false;
}