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