From 44598a3ab36d7fa0b4d9aad665ba697199d20520 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Sun, 6 Aug 2023 10:45:33 -0400 Subject: [PATCH] fix --- lib/veilid_support/dht_support/dht_record_pool.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/veilid_support/dht_support/dht_record_pool.dart b/lib/veilid_support/dht_support/dht_record_pool.dart index a44bb2a..9d90ce5 100644 --- a/lib/veilid_support/dht_support/dht_record_pool.dart +++ b/lib/veilid_support/dht_support/dht_record_pool.dart @@ -138,15 +138,16 @@ class DHTRecordPool with AsyncTableDBBacked { 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'); } }