mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-09-24 14:28:30 -04:00
encryption and dht work
This commit is contained in:
parent
7831deabd3
commit
c63eee26fd
9 changed files with 246 additions and 159 deletions
|
@ -91,6 +91,15 @@ class DHTRecord {
|
|||
}
|
||||
}
|
||||
|
||||
Future<T> maybeDeleteScope<T>(
|
||||
bool delete, Future<T> Function(DHTRecord) scopeFunction) async {
|
||||
if (delete) {
|
||||
return deleteScope(scopeFunction);
|
||||
} else {
|
||||
return scope(scopeFunction);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Uint8List?> get(
|
||||
{int subkey = -1,
|
||||
bool forceRefresh = false,
|
||||
|
|
|
@ -120,12 +120,12 @@ class DHTRecordPool with AsyncTableDBBacked<DHTRecordPoolAllocations> {
|
|||
while (currentDeps.isNotEmpty) {
|
||||
final nextDep = currentDeps.removeLast();
|
||||
|
||||
// Ensure we get the exclusive lock on this record
|
||||
await _recordOpened(nextDep);
|
||||
|
||||
// Remove this child from its parent
|
||||
await _removeDependency(nextDep);
|
||||
|
||||
// Ensure all records are closed before delete
|
||||
assert(!_opened.containsKey(nextDep), 'should not delete opened record');
|
||||
|
||||
allDeps.add(nextDep);
|
||||
final childDeps =
|
||||
_state.childrenByParent[nextDep.toJson()]?.toList() ?? [];
|
||||
|
@ -136,6 +136,7 @@ class DHTRecordPool with AsyncTableDBBacked<DHTRecordPoolAllocations> {
|
|||
final allFutures = <Future<void>>[];
|
||||
for (final dep in allDeps) {
|
||||
allFutures.add(_routingContext.deleteDHTRecord(dep));
|
||||
recordClosed(dep);
|
||||
}
|
||||
await Future.wait(allFutures);
|
||||
}
|
||||
|
@ -324,4 +325,10 @@ class DHTRecordPool with AsyncTableDBBacked<DHTRecordPoolAllocations> {
|
|||
defaultSubkey: defaultSubkey,
|
||||
crypto: crypto,
|
||||
);
|
||||
|
||||
/// Get the parent of a DHTRecord key if it exists
|
||||
TypedKey? getParentRecord(TypedKey child) {
|
||||
final childJson = child.toJson();
|
||||
return _state.parentByChild[childJson];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue