mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-01-26 07:25:55 -05: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) {
|
void _validateParent(TypedKey? parent, TypedKey child) {
|
||||||
final childJson = child.toJson();
|
final childJson = child.toJson();
|
||||||
|
final existingParent = _state.parentByChild[childJson];
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
if (_state.parentByChild.containsKey(childJson)) {
|
if (existingParent != null) {
|
||||||
throw StateError('Child is already parented: $child');
|
throw StateError('Child is already parented: $child');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_state.rootRecords.contains(child)) {
|
if (_state.rootRecords.contains(child)) {
|
||||||
throw StateError('Child already added as root: $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');
|
throw StateError('Child has two parents: $child <- $parent');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user