Skip to content

Commit

Permalink
adds escrow clearing
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Griffin <[email protected]>
  • Loading branch information
m00sey committed Sep 17, 2024
1 parent c9f4efb commit 878a4ab
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/keri/app/cli/commands/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ def __init__(self, args):
super(CleanDoer, self).__init__()

def recur(self, tyme):

hby = existing.setupHby(name=self.args.name, base=self.args.base,
bran=self.args.bran, temp=self.args.temp)

print("Clearing escrows...")
hby.db.clearEscrows()
print("Finished")

print("Migrating...")
hby.db.migrate()
print("Finished")
Expand All @@ -59,6 +63,6 @@ def recur(self, tyme):

print("Database open, performing clean...")
hby.db.clean()
print("Finished.")
print("Finished")

return True
Empty file.
59 changes: 59 additions & 0 deletions src/keri/app/cli/commands/escrow/clear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- encoding: utf-8 -*-
"""
KERI
keri.kli.commands module
"""
import argparse

from hio import help
from hio.base import doing

from keri import kering
from keri.app.cli.common import existing
from keri.core import coring, serdering
from keri.db import koming, subing, dbing
from keri.db.basing import KeyStateRecord, StateEERecord
from keri.kering import ConfigurationError, Version
from keri.vdr import viring

logger = help.ogler.getLogger()

parser = argparse.ArgumentParser(description='Clear escrows')
parser.set_defaults(handler=lambda args: handler(args),
transferable=True)
parser.add_argument('--name', '-n', help='keystore name and file location of KERI keystore', required=True)
parser.add_argument('--base', '-b', help='additional optional prefix to file location of KERI keystore',
required=False, default="")
parser.add_argument('--passcode', '-p', help='21 character encryption passcode for keystore (is not saved)',
dest="bran", default=None) # passcode => bran
parser.add_argument('--force', action="store_true", required=False,
help='True means perform clear without prompting the user')


def handler(args):
if not args.force:
print()
print("This command will clear all escrows and is not reversible.")
print()
yn = input("Are you sure you want to continue? [y|N]: ")

if yn not in ("y", "Y"):
print("...exiting")
return []

kwa = dict(args=args)
return [doing.doify(clear, **kwa)]


def clear(tymth, tock=0.0, **opts):
""" Command line clear handler
"""
_ = (yield tock)
args = opts["args"]
name = args.name
base = args.base
bran = args.bran

with existing.existingHby(name=name, base=base, bran=bran) as hby:
hby.db.clearEscrows()
7 changes: 1 addition & 6 deletions src/keri/app/cli/commands/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,7 @@ def migrate(tymth, tock=0.0, **opts):

# clear escrows
print("clearing escrows")
hby.db.gpwe.trim()
hby.db.gdee.trim()
hby.db.dpwe.trim()
hby.db.gpse.trim()
hby.db.epse.trim()
hby.db.dune.trim()
hby.db.clearEscrows()

except ConfigurationError:
print(f"identifier prefix for {name} does not exist, incept must be run first", )
Expand Down
9 changes: 9 additions & 0 deletions src/keri/db/basing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,15 @@ def migrate(self):

self.version = keri.__version__

def clearEscrows(self):
"""
Clear all escrows
"""
for escrow in [self.misfits, self.delegables, self.ures, self.vres, self.pses, self.pwes, self.pdes, self.udes,
self.uwes, self.ooes, self.ldes, self.rpes, self.epsd, self.eoobi, self.dpub, self.gpwe, self.gdee,
self.dpwe, self.gpse, self.epse, self.dune]:
escrow.trim()

@property
def current(self):
""" Current property determines if we are at the current database migration state.
Expand Down

0 comments on commit 878a4ab

Please sign in to comment.