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

Allowing prefixes in identifiers endpoint #264

Closed
wants to merge 16 commits into from
Closed
98 changes: 57 additions & 41 deletions src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
from dataclasses import asdict
from urllib.parse import urlparse, urljoin
from types import MappingProxyType

import falcon
from falcon import media
Expand Down Expand Up @@ -289,6 +290,8 @@ def __init__(self, hby, rgy, agentHab, agency, caid, **opts):
self.agentHab = agentHab
self.agency = agency
self.caid = caid
self.cfd = MappingProxyType(dict(self.hby.cf.get()) if self.hby.cf is not None else dict())
self.tocks = MappingProxyType(self.cfd.get("tocks", {}))

self.swain = delegating.Anchorer(hby=hby, proxy=agentHab)
self.counselor = Counselor(hby=hby, swain=self.swain, proxy=agentHab)
Expand Down Expand Up @@ -364,19 +367,25 @@ def __init__(self, hby, rgy, agentHab, agency, caid, **opts):
local=True) # disable misfit escrow until we can add another parser for remote.

doers.extend([
Initer(agentHab=agentHab, caid=caid),
Querier(hby=hby, agentHab=agentHab, kvy=self.kvy, queries=self.queries),
Initer(agentHab=agentHab, caid=caid, tock=self.tocks.get("initer", 0.0)),
Querier(hby=hby, agentHab=agentHab, kvy=self.kvy, queries=self.queries,
tock=self.tocks.get("querier", 0.0)),
Escrower(kvy=self.kvy, rgy=self.rgy, rvy=self.rvy, tvy=self.tvy, exc=self.exc, vry=self.verifier,
registrar=self.registrar, credentialer=self.credentialer),
ParserDoer(kvy=self.kvy, parser=self.parser),
Witnesser(receiptor=receiptor, witners=self.witners),
Delegator(agentHab=agentHab, swain=self.swain, anchors=self.anchors),
ExchangeSender(hby=hby, agentHab=agentHab, exc=self.exc, exchanges=self.exchanges),
Granter(hby=hby, rgy=rgy, agentHab=agentHab, exc=self.exc, grants=self.grants),
Admitter(hby=hby, witq=self.witq, psr=self.parser, agentHab=agentHab, exc=self.exc, admits=self.admits),
GroupRequester(hby=hby, agentHab=agentHab, counselor=self.counselor, groups=self.groups),
SeekerDoer(seeker=self.seeker, cues=self.verifier.cues),
ExchangeCueDoer(seeker=self.exnseeker, cues=self.exc.cues, queries=self.queries)
registrar=self.registrar, credentialer=self.credentialer, tock=self.tocks.get("escrower", 0.0)),
ParserDoer(kvy=self.kvy, parser=self.parser, tock=self.tocks.get("parser", 0.0)),
Witnesser(receiptor=receiptor, witners=self.witners, tock=self.tocks.get("witnesser", 0.0)),
Delegator(agentHab=agentHab, swain=self.swain, anchors=self.anchors, tock=self.tocks.get("delegator", 0.0)),
ExchangeSender(hby=hby, agentHab=agentHab, exc=self.exc, exchanges=self.exchanges,
tock=self.tocks.get("exchangeSender", 0.0)),
Granter(hby=hby, rgy=rgy, agentHab=agentHab, exc=self.exc, grants=self.grants,
tock=self.tocks.get("granter", 0.0)),
Admitter(hby=hby, witq=self.witq, psr=self.parser, agentHab=agentHab, exc=self.exc, admits=self.admits,
tock=self.tocks.get("admitter", 0.0)),
GroupRequester(hby=hby, agentHab=agentHab, counselor=self.counselor, groups=self.groups,
tock=self.tocks.get("groupRequester", 0.0)),
SeekerDoer(seeker=self.seeker, cues=self.verifier.cues, tock=self.tocks.get("seeker", 0.0)),
ExchangeCueDoer(seeker=self.exnseeker, cues=self.exc.cues, queries=self.queries,
tock=self.tocks.get("exchangecue", 0.0)),
])

super(Agent, self).__init__(doers=doers, always=True, **opts)
Expand Down Expand Up @@ -412,10 +421,11 @@ def inceptExtern(self, pre, verfers, digers, **kwargs):

class ParserDoer(doing.Doer):

def __init__(self, kvy, parser):
def __init__(self, kvy, parser, tock=0.0):
self.kvy = kvy
self.parser = parser
super(ParserDoer, self).__init__()
self.tock = tock
super(ParserDoer, self).__init__(tock=self.tock)

def recur(self, tyme=None):
if self.parser.ims:
Expand All @@ -426,10 +436,11 @@ def recur(self, tyme=None):

class Witnesser(doing.Doer):

def __init__(self, receiptor, witners):
def __init__(self, receiptor, witners, tock=0.0):
self.receiptor = receiptor
self.witners = witners
super(Witnesser, self).__init__()
self.tock = tock
super(Witnesser, self).__init__(tock=self.tock)

def recur(self, tyme=None):
while True:
Expand All @@ -450,11 +461,12 @@ def recur(self, tyme=None):

class Delegator(doing.Doer):

def __init__(self, agentHab, swain, anchors):
def __init__(self, agentHab, swain, anchors, tock=0.0):
self.agentHab = agentHab
self.swain = swain
self.anchors = anchors
super(Delegator, self).__init__()
self.tock = tock
super(Delegator, self).__init__(tock=self.tock)

def recur(self, tyme=None):
if self.anchors:
Expand All @@ -467,12 +479,13 @@ def recur(self, tyme=None):

class ExchangeSender(doing.DoDoer):

def __init__(self, hby, agentHab, exc, exchanges):
def __init__(self, hby, agentHab, exc, exchanges, tock=0.0):
self.hby = hby
self.agentHab = agentHab
self.exc = exc
self.exchanges = exchanges
super(ExchangeSender, self).__init__(always=True)
self.tock = tock
super(ExchangeSender, self).__init__(always=True, tock=self.tock)

def recur(self, tyme, deeds=None):
if self.exchanges:
Expand Down Expand Up @@ -507,13 +520,14 @@ def recur(self, tyme, deeds=None):

class Granter(doing.DoDoer):

def __init__(self, hby, rgy, agentHab, exc, grants):
def __init__(self, hby, rgy, agentHab, exc, grants, tock=0.0):
self.hby = hby
self.rgy = rgy
self.agentHab = agentHab
self.exc = exc
self.grants = grants
super(Granter, self).__init__(always=True)
self.tock = tock
super(Granter, self).__init__(always=True, tock=self.tock)

def recur(self, tyme, deeds=None):
if self.grants:
Expand Down Expand Up @@ -553,14 +567,15 @@ def recur(self, tyme, deeds=None):

class Admitter(doing.Doer):

def __init__(self, hby, witq, psr, agentHab, exc, admits):
def __init__(self, hby, witq, psr, agentHab, exc, admits, tock=0.0):
self.hby = hby
self.agentHab = agentHab
self.witq = witq
self.psr = psr
self.exc = exc
self.admits = admits
super(Admitter, self).__init__()
self.tock = tock
super(Admitter, self).__init__(tock=self.tock)

def recur(self, tyme):
if self.admits:
Expand Down Expand Up @@ -600,11 +615,11 @@ def recur(self, tyme):

class SeekerDoer(doing.Doer):

def __init__(self, seeker, cues):
def __init__(self, seeker, cues, tock=0.0):
self.seeker = seeker
self.cues = cues

super(SeekerDoer, self).__init__()
self.tock = tock
super(SeekerDoer, self).__init__(tock=self.tock)

def recur(self, tyme=None):
if self.cues:
Expand All @@ -623,12 +638,12 @@ def recur(self, tyme=None):

class ExchangeCueDoer(doing.Doer):

def __init__(self, seeker, cues, queries):
def __init__(self, seeker, cues, queries, tock=0.0):
self.seeker = seeker
self.cues = cues
self.queries = queries

super(ExchangeCueDoer, self).__init__()
self.tock = tock
super(ExchangeCueDoer, self).__init__(tock=self.tock)

def recur(self, tyme=None):
if self.cues:
Expand All @@ -649,10 +664,11 @@ def recur(self, tyme=None):


class Initer(doing.Doer):
def __init__(self, agentHab, caid):
def __init__(self, agentHab, caid, tock=0.0):
self.agentHab = agentHab
self.caid = caid
super(Initer, self).__init__()
self.tock = tock
super(Initer, self).__init__(tock=self.tock)

def recur(self, tyme):
""" Prints Agent name and prefix """
Expand All @@ -665,13 +681,13 @@ def recur(self, tyme):

class GroupRequester(doing.Doer):

def __init__(self, hby, agentHab, counselor, groups):
def __init__(self, hby, agentHab, counselor, groups, tock=0.0):
self.hby = hby
self.agentHab = agentHab
self.counselor = counselor
self.groups = groups

super(GroupRequester, self).__init__()
self.tock = tock
super(GroupRequester, self).__init__(tock=self.tock)

def recur(self, tyme):
""" Checks cue for group proceccing requests and processes any with Counselor """
Expand All @@ -691,13 +707,13 @@ def recur(self, tyme):

class Querier(doing.DoDoer):

def __init__(self, hby, agentHab, queries, kvy):
def __init__(self, hby, agentHab, queries, kvy, tock=0.0):
self.hby = hby
self.agentHab = agentHab
self.queries = queries
self.kvy = kvy

super(Querier, self).__init__(always=True)
self.tock = tock
super(Querier, self).__init__(always=True, tock=self.tock)

def recur(self, tyme, deeds=None):
""" Processes query reqests submitting any on the cue"""
Expand All @@ -724,7 +740,7 @@ def recur(self, tyme, deeds=None):


class Escrower(doing.Doer):
def __init__(self, kvy, rgy, rvy, tvy, exc, vry, registrar, credentialer):
def __init__(self, kvy, rgy, rvy, tvy, exc, vry, registrar, credentialer, tock=0.0):
""" Recuring process or escrows for all components in an Agent

Parameters:
Expand All @@ -745,8 +761,9 @@ def __init__(self, kvy, rgy, rvy, tvy, exc, vry, registrar, credentialer):
self.vry = vry
self.registrar = registrar
self.credentialer = credentialer
self.tock = tock

super(Escrower, self).__init__()
super(Escrower, self).__init__(tock=self.tock)

def recur(self, tyme):
""" Process all escrows once per loop. """
Expand All @@ -760,7 +777,6 @@ def recur(self, tyme):
self.vry.processEscrows()
self.registrar.processEscrows()
self.credentialer.processEscrows()

return False


Expand Down
Loading