Skip to content

Commit

Permalink
fix: re-cue filtered kvy/tvy cues from respondant (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
iFergal authored Jun 5, 2024
1 parent 4606d0f commit 38cc289
Showing 1 changed file with 65 additions and 60 deletions.
125 changes: 65 additions & 60 deletions src/keri/app/storing.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,65 +219,70 @@ def cueDo(self, tymth=None, tock=0.0):
_ = (yield self.tock)

while True:
while self.cues: # iteratively process each cue in cues
cue = self.cues.pull() # self.cues.popleft()
cueKin = cue["kin"] # type or kind of cue
if cueKin in ("receipt",): # cue to receipt a received event from other pre
serder = cue["serder"] # Serder of received event for other pre
cuedKed = serder.ked
cuedPrefixer = coring.Prefixer(qb64=cuedKed["i"])

# If respondant configured with list of acceptable AIDs to witness for, check them here
if self.aids is not None and cuedPrefixer.qb64 not in self.aids:
continue

if cuedPrefixer.qb64 in self.hby.kevers:
kever = self.hby.kevers[cuedPrefixer.qb64]
owits = oset(kever.wits)
if match := owits.intersection(self.hby.prefixes):
pre = match.pop()
hab = self.hby.habByPre(pre)
if hab is None:
continue

raw = hab.receipt(serder)
rserder = serdering.SerderKERI(raw=raw)
del raw[:rserder.size]
self.postman.send(serder.pre, topic="receipt", serder=rserder, hab=hab, attachment=raw)

elif cueKin in ("replay",):
src = cue["src"]
dest = cue["dest"]
msgs = cue["msgs"]

hab = self.hby.habByPre(src)
if hab is None:
continue

if dest not in self.hby.kevers:
continue

for msg in msgs:
raw = bytearray(msg)
serder = serdering.SerderKERI(raw=raw)
del raw[:serder.size]
self.postman.send(dest, topic="replay", serder=serder, hab=hab, attachment=raw)

elif cueKin in ("reply",):
src = cue["src"]
serder = cue["serder"]

dest = cue["dest"]

if dest not in self.hby.kevers:
continue

hab = self.hby.habByPre(src)
if hab is None:
continue

atc = hab.endorse(serder)
del atc[:serder.size]
self.postman.send(hab=hab, dest=dest, topic="reply", serder=serder, attachment=atc)
while not self.cues:
yield self.tock

cue = self.cues.pull() # self.cues.popleft()
cueKin = cue["kin"] # type or kind of cue
if cueKin in ("receipt",): # cue to receipt a received event from other pre
serder = cue["serder"] # Serder of received event for other pre
cuedKed = serder.ked
cuedPrefixer = coring.Prefixer(qb64=cuedKed["i"])

# If respondant configured with list of acceptable AIDs to witness for, check them here
if self.aids is not None and cuedPrefixer.qb64 not in self.aids:
continue

if cuedPrefixer.qb64 in self.hby.kevers:
kever = self.hby.kevers[cuedPrefixer.qb64]
owits = oset(kever.wits)
if match := owits.intersection(self.hby.prefixes):
pre = match.pop()
hab = self.hby.habByPre(pre)
if hab is None:
continue

raw = hab.receipt(serder)
rserder = serdering.SerderKERI(raw=raw)
del raw[:rserder.size]
self.postman.send(serder.pre, topic="receipt", serder=rserder, hab=hab, attachment=raw)

elif cueKin in ("replay",):
src = cue["src"]
dest = cue["dest"]
msgs = cue["msgs"]

hab = self.hby.habByPre(src)
if hab is None:
continue

if dest not in self.hby.kevers:
continue

for msg in msgs:
raw = bytearray(msg)
serder = serdering.SerderKERI(raw=raw)
del raw[:serder.size]
self.postman.send(dest, topic="replay", serder=serder, hab=hab, attachment=raw)

elif cueKin in ("reply",):
src = cue["src"]
serder = cue["serder"]

dest = cue["dest"]

if dest not in self.hby.kevers:
continue

hab = self.hby.habByPre(src)
if hab is None:
continue

atc = hab.endorse(serder)
del atc[:serder.size]
self.postman.send(hab=hab, dest=dest, topic="reply", serder=serder, attachment=atc)

else:
self.cues.push(cue)

yield self.tock

0 comments on commit 38cc289

Please sign in to comment.