Skip to content

Commit

Permalink
Merge pull request #826 from SmithSamuelM/main
Browse files Browse the repository at this point in the history
Now uses versioned Counter class in core.counting everywhere. Old unversioned coring.Counter has been removed.
  • Loading branch information
SmithSamuelM authored Jul 27, 2024
2 parents 9709867 + 46dfb35 commit 7d78294
Show file tree
Hide file tree
Showing 48 changed files with 986 additions and 1,670 deletions.
7 changes: 4 additions & 3 deletions src/keri/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from . import httping, forwarding
from .. import help
from .. import kering
from .. import core
from ..core import eventing, parsing, coring, serdering, indexing
from ..core.coring import CtrDex
from ..db import dbing
from ..kering import Roles

Expand Down Expand Up @@ -104,7 +104,7 @@ def receipt(self, pre, sn=None, auths=None):
del rct[:rserder.size]

# pull off the count code
coring.Counter(qb64b=rct, strip=True)
core.Counter(qb64b=rct, strip=True, gvrsn=kering.Vrsn_1_0)
rcts[wit] = rct
else:
print(f"invalid response {rep.status} from witnesses {wit}")
Expand All @@ -124,7 +124,8 @@ def receipt(self, pre, sn=None, auths=None):
sn=sn,
said=ser.said)
msg.extend(rserder.raw)
msg.extend(coring.Counter(code=CtrDex.NonTransReceiptCouples, count=len(wigs)).qb64b)
msg.extend(core.Counter(core.Codens.NonTransReceiptCouples,
count=len(wigs), gvrsn=kering.Vrsn_1_0).qb64b)
for wig in wigs:
msg.extend(wig)

Expand Down
2 changes: 1 addition & 1 deletion src/keri/app/forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def handle(self, serder, attachments=None):
pevt = bytearray()
for pather, atc in attachments:
ked = pather.resolve(embeds)
sadder = coring.Sadder(ked=ked, kind=eventing.Serials.json)
sadder = coring.Sadder(ked=ked, kind=eventing.Kinds.json)
pevt.extend(sadder.raw)
pevt.extend(atc)

Expand Down
10 changes: 5 additions & 5 deletions src/keri/app/grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from hio.base import doing
from hio.help import decking

from .. import kering
from .. import kering, core
from .. import help
from ..app import delegating, agenting
from ..core import coring, routing, eventing, parsing, serdering, indexing
Expand Down Expand Up @@ -518,14 +518,14 @@ def getEscrowedEvent(db, pre, sn):

msg = bytearray()
msg.extend(serder.raw)
msg.extend(coring.Counter(code=coring.CtrDex.ControllerIdxSigs,
count=len(sigs)).qb64b) # attach cnt
msg.extend(core.Counter(core.Codens.ControllerIdxSigs,
count=len(sigs), gvrsn=kering.Vrsn_1_0).qb64b) # attach cnt
for sig in sigs:
msg.extend(sig.qb64b) # attach sig

if couple is not None:
msg.extend(coring.Counter(code=coring.CtrDex.SealSourceCouples,
count=1).qb64b)
msg.extend(core.Counter(core.Codens.SealSourceCouples,
count=1, gvrsn=kering.Vrsn_1_0).qb64b)
msg.extend(couple)

return msg
Expand Down
17 changes: 9 additions & 8 deletions src/keri/app/habbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from .. import help
from .. import kering
from .. import core
from ..core import coring, eventing, parsing, routing, serdering, indexing
from ..core import (coring, eventing, parsing, routing, serdering, indexing,
Counter, Codens)
from ..db import dbing, basing
from ..kering import MissingSignatureError, Roles

Expand Down Expand Up @@ -1567,8 +1568,8 @@ def makeOtherEvent(self, pre, sn):
dig = bytes(dig)
key = dbing.dgKey(pre, dig) # digest key
msg.extend(self.db.getEvt(key))
msg.extend(coring.Counter(code=coring.CtrDex.ControllerIdxSigs,
count=self.db.cntSigs(key)).qb64b) # attach cnt
msg.extend(Counter(Codens.ControllerIdxSigs, count=self.db.cntSigs(key),
gvrsn=kering.Vrsn_1_0).qb64b) # attach cnt
for sig in self.db.getSigsIter(key):
msg.extend(sig) # attach sig
return msg
Expand Down Expand Up @@ -2035,14 +2036,14 @@ def makeOwnEvent(self, sn, allowPartiallySigned=False):
serder, sigs, couple = self.getOwnEvent(sn=sn,
allowPartiallySigned=allowPartiallySigned)
msg.extend(serder.raw)
msg.extend(coring.Counter(code=coring.CtrDex.ControllerIdxSigs,
count=len(sigs)).qb64b) # attach cnt
msg.extend(Counter(Codens.ControllerIdxSigs, count=len(sigs),
gvrsn=kering.Vrsn_1_0).qb64b) # attach cnt
for sig in sigs:
msg.extend(sig.qb64b) # attach sig

if couple is not None:
msg.extend(coring.Counter(code=coring.CtrDex.SealSourceCouples,
count=1).qb64b)
msg.extend(Counter(Codens.SealSourceCouples, count=1,
gvrsn=kering.Vrsn_1_0).qb64b)
msg.extend(couple)

return msg
Expand Down Expand Up @@ -2727,7 +2728,7 @@ def make(self, *, code=coring.MtrDex.Blake3_256, transferable=True, isith=None,
rmids=self.rmids)
self.save(habord)
self.prefixes.add(self.pre)

# during delegation initialization of a habitat we ignore the MissingDelegationError and
# MissingSignatureError
try:
Expand Down
11 changes: 6 additions & 5 deletions src/keri/app/indirecting.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from . import directing, storing, httping, forwarding, agenting, oobiing
from .habbing import GroupHab
from .. import help, kering
from ..core import eventing, parsing, routing, coring, serdering
from ..core import (eventing, parsing, routing, coring, serdering,
Counter, Codens)
from ..core.coring import Ilks
from ..db import basing, dbing
from ..end import ending
Expand Down Expand Up @@ -893,7 +894,7 @@ def on_post(self, req, rep):
rep.set_header('connection', "close")

cr = httping.parseCesrHttpRequest(req=req)
sadder = coring.Sadder(ked=cr.payload, kind=eventing.Serials.json)
sadder = coring.Sadder(ked=cr.payload, kind=eventing.Kinds.json)
msg = bytearray(sadder.raw)
msg.extend(cr.attachments.encode("utf-8"))

Expand Down Expand Up @@ -1063,7 +1064,7 @@ def on_post(self, req, rep):
rep.set_header('connection', "close")

cr = httping.parseCesrHttpRequest(req=req)
serder = serdering.SerderKERI(sad=cr.payload, kind=eventing.Serials.json)
serder = serdering.SerderKERI(sad=cr.payload, kind=eventing.Kinds.json)

pre = serder.ked["i"]
if self.aids is not None and pre not in self.aids:
Expand Down Expand Up @@ -1142,8 +1143,8 @@ def on_get(self, req, rep):
said=said.decode("utf-8"))
rct = bytearray(rserder.raw)
if wigs := self.hab.db.getWigs(key=dgkey):
rct.extend(coring.Counter(code=coring.CtrDex.WitnessIdxSigs,
count=len(wigs)).qb64b)
rct.extend(Counter(Codens.WitnessIdxSigs, count=len(wigs),
gvrsn=kering.Vrsn_1_0).qb64b)
for wig in wigs:
rct.extend(wig)

Expand Down
8 changes: 6 additions & 2 deletions src/keri/app/signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
keri.app.signing module
"""
from ..kering import Vrsn_1_0, Vrsn_2_0
from ..app.habbing import GroupHab
from ..core import coring, eventing
from .. import core
from ..core import coring, eventing, counting



def serialize(creder, prefixer, seqner, saider):
craw = bytearray(creder.raw)
craw.extend(coring.Counter(coring.CtrDex.SealSourceTriples, count=1).qb64b)
craw.extend(core.Counter(core.Codens.SealSourceTriples, count=1,
gvrsn=Vrsn_1_0).qb64b)
craw.extend(prefixer.qb64b)
craw.extend(seqner.qb64b)
craw.extend(saider.qb64b)
Expand Down
3 changes: 2 additions & 1 deletion src/keri/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@

from .coring import Tholder
from .indexing import Indexer, Siger, IdrDex, IdxSigDex
from .signing import (Signer, Salter, Cipher, Encrypter, Decrypter, )
from .signing import Signer, Salter, Cipher, Encrypter, Decrypter
from .counting import Counter, Codens
Loading

0 comments on commit 7d78294

Please sign in to comment.