Skip to content

Commit

Permalink
added test for prefix in locallyOwned to not be in db.groups.
Browse files Browse the repository at this point in the history
Changes db.gids to .groups
  • Loading branch information
SmithSamuelM committed Dec 31, 2023
1 parent 50de552 commit bf678a2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/keri/app/habbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ def deleteHab(self, name):

del self.habs[hab.pre]
self.db.prefixes.remove(hab.pre)
if hab.pre in self.db.gids:
self.db.gids.remove(hab.pre)
if hab.pre in self.db.groups:
self.db.groups.remove(hab.pre)

return True

Expand Down
16 changes: 10 additions & 6 deletions src/keri/core/eventing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ def groups(self):
"""
Returns .db.gids oset of group hab ids (prefixes)
"""
return self.db.gids
return self.db.groups


@property
Expand All @@ -1782,17 +1782,21 @@ def transferable(self):


def locallyOwned(self, pre):
"""Returns True if pre is in .prefixes False otherwise. Indicates that
provided identifier prefix is controlled by a local controller from
.prefixes
"""Returns True if pre is in .prefixes and not in .groups
False otherwise.
Indicates that provided identifier prefix is controlled by a local
controller from .prefixes but is not a group with local member.
i.e pre is a locally owned (controlled) AID (identifier prefix)
Returns:
(bool): True if pre is local hab but not group hab
Parameters:
pre (str|None): qb64 identifier prefix or None
pre (str|None): qb64 identifier prefix or None
"""
pre = pre if pre is not None else ''
return pre in self.prefixes
return pre in self.prefixes and pre not in self.groups


def locallyMembered(self, pre):
Expand Down
12 changes: 6 additions & 6 deletions src/keri/db/basing.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def __init__(self, headDirPath=None, reopen=False, **kwa):
"""
self.prefixes = oset() # should change to hids for hab ids
self.gids = oset() # group hab ids
self.groups = oset() # group hab ids
self._kevers = dbdict()
self._kevers.db = self # assign db for read through cache of kevers

Expand Down Expand Up @@ -1153,7 +1153,7 @@ def reload(self):
self.kevers[kever.prefixer.qb64] = kever
self.prefixes.add(kever.prefixer.qb64)
if data.mid: # group hab
self.gids.add(data.hid)
self.groups.add(data.hid)

elif data.mid is None: # in .habs but no corresponding key state and not a group so remove
removes.append(keys) # no key state or KEL event for .hab record
Expand All @@ -1175,7 +1175,7 @@ def reload(self):
self.kevers[kever.prefixer.qb64] = kever
self.prefixes.add(kever.prefixer.qb64)
if data.mid: # group hab
self.gids.add(data.hid)
self.groups.add(data.hid)
elif data.mid is None: # in .habs but no corresponding key state and not a group so remove
removes.append(keys) # no key state or KEL event for .hab record

Expand Down Expand Up @@ -1222,7 +1222,7 @@ def clean(self):
copy.habs.put(keys=keys, val=val)
copy.prefixes.add(val.hid)
if val.mid: # a group hab
copy.gids.add(val.hid)
copy.groups.add(val.hid)

# ToDo XXXX
# is this obsolete? Should this be removed or should this be
Expand Down Expand Up @@ -1264,8 +1264,8 @@ def clean(self):
self.prefixes.update(copy.prefixes)

# clear and clone .gids
self.gids.clear()
self.gids.update(copy.gids)
self.groups.clear()
self.groups.update(copy.groups)

with reopenDB(db=self, reuse=True): # make sure can reopen
if not isinstance(self.env, lmdb.Environment):
Expand Down

0 comments on commit bf678a2

Please sign in to comment.