mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-10-01 06:55:46 -04:00
fix
This commit is contained in:
parent
3c2c8827bb
commit
44598a3ab3
@ -138,15 +138,16 @@ class DHTRecordPool with AsyncTableDBBacked<DHTRecordPoolAllocations> {
|
||||
|
||||
void _validateParent(TypedKey? parent, TypedKey child) {
|
||||
final childJson = child.toJson();
|
||||
final existingParent = _state.parentByChild[childJson];
|
||||
if (parent == null) {
|
||||
if (_state.parentByChild.containsKey(childJson)) {
|
||||
if (existingParent != null) {
|
||||
throw StateError('Child is already parented: $child');
|
||||
}
|
||||
} else {
|
||||
if (_state.rootRecords.contains(child)) {
|
||||
throw StateError('Child already added as root: $child');
|
||||
}
|
||||
if (_state.parentByChild[childJson] != parent) {
|
||||
if (existingParent != null && existingParent != parent) {
|
||||
throw StateError('Child has two parents: $child <- $parent');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user