Skip to content

Commit

Permalink
Merge pull request #649 from SmithSamuelM/misfit
Browse files Browse the repository at this point in the history
More improvement on local vs remote support
  • Loading branch information
SmithSamuelM authored Dec 31, 2023
2 parents d7755c9 + bf678a2 commit 923f40f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 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
26 changes: 19 additions & 7 deletions src/keri/core/eventing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,14 @@ def prefixes(self):
return self.db.prefixes


@property
def groups(self):
"""
Returns .db.gids oset of group hab ids (prefixes)
"""
return self.db.groups


@property
def transferable(self):
"""
Expand All @@ -1774,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 Expand Up @@ -2957,7 +2969,7 @@ def escrowMFEvent(self, serder, sigers, wigers=None,
if seqner and saider:
couple = seqner.qb64b + saider.qb64b
self.db.putPde(dgkey, couple) # idempotent
self.db.mfes.add(snKey(serder.preb, serder.sn), serder.saidb)
self.db.misfits.add(snKey(serder.preb, serder.sn), serder.saidb)
# log escrowed
logger.info("Kever state: escrowed misfit event=\n%s\n",
json.dumps(serder.ked, indent=1))
Expand Down Expand Up @@ -4607,7 +4619,7 @@ def escrowMFEvent(self, serder, sigers, wigers=None,
if seqner and saider:
couple = seqner.qb64b + saider.qb64b
self.db.putPde(dgkey, couple) # idempotent
self.db.mfes.add(snKey(serder.preb, serder.sn), serder.saidb)
self.db.misfits.add(snKey(serder.preb, serder.sn), serder.saidb)
# log escrowed
logger.info("Kevery process: escrowed misfit event=\n%s\n",
json.dumps(serder.ked, indent=1))
Expand Down
14 changes: 7 additions & 7 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 @@ -903,7 +903,7 @@ def reopen(self, **kwa):
subkey='esrs.')

# misfit escrows whose processing may change the .esrs event source record
self.mfes = subing.CesrIoSetSuber(db=self, subkey='mfes.', klas=coring.Diger)
self.misfits = subing.CesrIoSetSuber(db=self, subkey='mfes.', klas=coring.Diger)

# events as ordered by first seen ordinals
self.fons = subing.CesrSuber(db=self, subkey='fons.', klas=coring.Seqner)
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 923f40f

Please sign in to comment.