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

feat: use SAID for long running operation oid instead of identifier prefix #289

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,20 +1218,21 @@ def on_post(req, rep):
pre = httping.getRequiredParam(body, "pre")
qry = dict(pre=pre)

meta = dict()
oid = pre
if "anchor" in body:
meta["anchor"] = body["anchor"]
qry["anchor"] = body["anchor"]
oid = f"{pre}.{body["anchor"]["d"]}"
elif "sn" in body:
meta["sn"] = body["sn"]
qry["sn"] = body["sn"]
oid = f"{pre}.{body["sn"]}"
else: # Must reset key state so we know when we have a new update.
for (keys, saider) in agent.hby.db.knas.getItemIter(keys=(pre,)):
agent.hby.db.knas.rem(keys)
agent.hby.db.ksns.rem((saider.qb64,))
agent.hby.db.ksns.rem((saider.qb64,))

qry.update(meta)
agent.queries.append(qry)
op = agent.monitor.submit(pre, longrunning.OpTypes.query, metadata=meta)
op = agent.monitor.submit(oid, longrunning.OpTypes.query, metadata=qry)

rep.status = falcon.HTTP_202
rep.content_type = "application/json"
Expand Down
31 changes: 15 additions & 16 deletions src/keria/app/aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def on_post(req, rep):
)
)
op = agent.monitor.submit(
serder.pre, longrunning.OpTypes.group, metadata=dict(sn=0)
serder.pre, longrunning.OpTypes.group, metadata=dict(pre=hab.pre, sn=0)
)

rep.content_type = "application/json"
Expand Down Expand Up @@ -622,7 +622,7 @@ def on_post(req, rep):
op = agent.monitor.submit(
hab.kever.prefixer.qb64,
longrunning.OpTypes.witness,
metadata=dict(sn=0),
metadata=dict(pre=hab.pre, sn=0),
)
rep.status = falcon.HTTP_202
rep.data = op.to_json().encode("utf-8")
Expand All @@ -632,7 +632,7 @@ def on_post(req, rep):
op = agent.monitor.submit(
hab.kever.prefixer.qb64,
longrunning.OpTypes.done,
metadata=dict(response=serder.ked),
metadata=dict(pre=hab.pre, response=serder.ked),
)
rep.data = op.to_json().encode("utf-8")

Expand Down Expand Up @@ -887,15 +887,15 @@ def rotate(agent, name, body):
)
)
op = agent.monitor.submit(
serder.pre, longrunning.OpTypes.group, metadata=dict(sn=serder.sn)
serder.said, longrunning.OpTypes.group, metadata=dict(pre=hab.pre, sn=serder.sn)
)

return op

if hab.kever.delpre:
agent.anchors.append(dict(alias=name, pre=hab.pre, sn=serder.sn))
op = agent.monitor.submit(
hab.kever.prefixer.qb64,
serder.said,
longrunning.OpTypes.delegation,
metadata=dict(pre=hab.pre, sn=serder.sn),
)
Expand All @@ -904,14 +904,14 @@ def rotate(agent, name, body):
if hab.kever.wits:
agent.witners.append(dict(serder=serder))
op = agent.monitor.submit(
hab.kever.prefixer.qb64,
serder.said,
longrunning.OpTypes.witness,
metadata=dict(sn=serder.sn),
metadata=dict(pre=hab.pre, sn=serder.sn),
)
return op

op = agent.monitor.submit(
hab.kever.prefixer.qb64,
serder.said,
longrunning.OpTypes.done,
metadata=dict(response=serder.ked),
)
Expand Down Expand Up @@ -945,28 +945,27 @@ def interact(agent, name, body):
if "group" in body:
agent.groups.append(dict(pre=hab.pre, serder=serder, sigers=sigers))
op = agent.monitor.submit(
serder.pre, longrunning.OpTypes.group, metadata=dict(sn=serder.sn)
serder.said, longrunning.OpTypes.group, metadata=dict(pre=hab.pre, sn=serder.sn)
)

return op

if hab.kever.wits:
agent.witners.append(dict(serder=serder))
op = agent.monitor.submit(
hab.kever.prefixer.qb64,
serder.said,
longrunning.OpTypes.witness,
metadata=dict(sn=serder.sn),
metadata=dict(pre=hab.pre, sn=serder.sn),
)
return op

op = agent.monitor.submit(
hab.kever.prefixer.qb64,
serder.said,
longrunning.OpTypes.done,
metadata=dict(response=serder.ked),
)
return op



@staticmethod
def submit_id(agent, name, body):
hab = agent.hby.habByName(name)
Expand All @@ -976,9 +975,9 @@ def submit_id(agent, name, body):
code = body.get("code")

if hab.kever.wits:
agent.submits.append(dict(alias=name,code=code))
agent.submits.append(dict(alias=name, code=code))
op = agent.monitor.submit(hab.kever.prefixer.qb64, longrunning.OpTypes.submit,
metadata=dict(alias=name,sn=hab.kever.sn))
metadata=dict(alias=name, sn=hab.kever.sn))
return op

raise falcon.HTTPBadRequest(title=f"invalid identifier submitted, {name} has no witnesses")
Expand Down
6 changes: 3 additions & 3 deletions src/keria/app/credentialing.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def on_post(self, req, rep, name):
seqner = coring.Seqner(sn=ixn.sn)
prefixer = coring.Prefixer(qb64=ixn.pre)
agent.registrar.incept(hab, registry, prefixer=prefixer, seqner=seqner, saider=coring.Saider(qb64=ixn.said))
op = agent.monitor.submit(hab.kever.prefixer.qb64, longrunning.OpTypes.registry,
metadata=dict(anchor=anchor, depends=op))
op = agent.monitor.submit(registry.regk, longrunning.OpTypes.registry,
metadata=dict(pre=hab.kever.prefixer.qb64, anchor=anchor, depends=op))

rep.status = falcon.HTTP_202
rep.data = op.to_json().encode("utf-8")
Expand Down Expand Up @@ -604,7 +604,7 @@ def on_post(self, req, rep, name):
agent.credentialer.validate(creder)
agent.registrar.issue(regk, iserder, anc)
agent.credentialer.issue(creder=creder, serder=iserder)
op = agent.monitor.submit(hab.kever.prefixer.qb64, longrunning.OpTypes.credential,
op = agent.monitor.submit(creder.said, longrunning.OpTypes.credential,
metadata=dict(ced=creder.sad, depends=op))

except kering.ConfigurationError as e:
Expand Down
6 changes: 3 additions & 3 deletions src/keria/app/delegating.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ def on_post(self, req, rep, name):

# successful approval returns the delegatee prefix
teepre = approveDelegation(hab, anc)
adop = agent.monitor.submit(hab.kever.prefixer.qb64, longrunning.OpTypes.delegation,
metadata=dict(teepre=teepre, anchor=anc, depends=op))
adop = agent.monitor.submit(anc["d"], longrunning.OpTypes.delegation,
2byrds marked this conversation as resolved.
Show resolved Hide resolved
metadata=dict(pre=hab.kever.prefixer.qb64, teepre=teepre, anchor=anc, depends=op))

try:
rep.status = falcon.HTTP_200
rep.content_type = "application/json"
Expand Down
2 changes: 1 addition & 1 deletion src/keria/app/grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def on_post(req, rep, name):

agent.inceptGroup(pre=gid, mpre=mhab.pre, verfers=verfers, digers=digers)
agent.groups.append(dict(pre=hab.pre, serder=serder, sigers=sigers, smids=smids, rmids=rmids))
op = agent.monitor.submit(serder.pre, longrunning.OpTypes.group, metadata=dict(sn=serder.sn))
op = agent.monitor.submit(serder.said, longrunning.OpTypes.group, metadata=dict(pre=serder.pre, sn=serder.sn))

rep.content_type = "application/json"
rep.status = falcon.HTTP_202
Expand Down
20 changes: 10 additions & 10 deletions src/keria/app/ipexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def sendAdmit(agent, hab, ked, sigs, rec):
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=rec, topic='credential'))
agent.admits.append(dict(said=ked['d'], pre=hab.pre))

return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
return agent.monitor.submit(serder.said, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
2byrds marked this conversation as resolved.
Show resolved Hide resolved

@staticmethod
def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
Expand Down Expand Up @@ -151,7 +151,7 @@ def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=[grant.ked['i']], topic="credential"))
agent.admits.append(dict(said=admitked['d'], pre=hab.pre))

return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
return agent.monitor.submit(serder.said, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))


class IpexGrantCollectionEnd:
Expand Down Expand Up @@ -226,7 +226,7 @@ def sendGrant(agent, hab, ked, sigs, atc, rec):
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=rec, topic='credential'))
agent.grants.append(dict(said=ked['d'], pre=hab.pre, rec=rec))

return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
return agent.monitor.submit(serder.said, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))

@staticmethod
def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
Expand Down Expand Up @@ -273,7 +273,7 @@ def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=[grantRec], topic="credential"))
agent.grants.append(dict(said=grant['d'], pre=hab.pre, rec=[grantRec]))

return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
return agent.monitor.submit(serder.said, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))


class IpexApplyCollectionEnd:
Expand Down Expand Up @@ -343,7 +343,7 @@ def sendApply(agent, hab, ked, sigs, rec):
agent.hby.psr.parseOne(ims=bytearray(ims))

agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=rec, topic='credential'))
return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
return agent.monitor.submit(serder.said, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))

@staticmethod
def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
Expand Down Expand Up @@ -387,7 +387,7 @@ def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
agent.hby.psr.parseOne(ims=ims)
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=[applyRec], topic="credential"))

return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
return agent.monitor.submit(serder.said, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))


class IpexOfferCollectionEnd:
Expand Down Expand Up @@ -457,7 +457,7 @@ def sendOffer(agent, hab, ked, sigs, atc, rec):
agent.hby.psr.parseOne(ims=bytearray(ims))

agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=rec, topic='credential'))
return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
return agent.monitor.submit(serder.said, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))

@staticmethod
def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
Expand Down Expand Up @@ -505,7 +505,7 @@ def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
agent.hby.psr.parseOne(ims=ims)
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=[offerRec], topic="credential"))

return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
return agent.monitor.submit(serder.said, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))


class IpexAgreeCollectionEnd:
Expand Down Expand Up @@ -574,7 +574,7 @@ def sendAgree(agent, hab, ked, sigs, rec):
agent.hby.psr.parseOne(ims=bytearray(ims))

agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=rec, topic='credential'))
return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
return agent.monitor.submit(serder.said, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))

@staticmethod
def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
Expand Down Expand Up @@ -622,4 +622,4 @@ def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
agent.hby.psr.parseOne(ims=ims)
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=[agreeRec], topic="credential"))

return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
return agent.monitor.submit(serder.said, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
Loading
Loading