Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: re-cue unmatched cues in Respondant #797

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading