From 2bb221deaae971d20ebb68ca51a5bad4591ccb1d Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sat, 22 Oct 2022 00:15:51 -0400 Subject: [PATCH 1/2] - Adding checkdb as a new parameter that will be used by counterparty to perform a database integrity check --- counterpartycli/server.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/counterpartycli/server.py b/counterpartycli/server.py index 9248dacb4e..354f8119c0 100755 --- a/counterpartycli/server.py +++ b/counterpartycli/server.py @@ -52,7 +52,8 @@ [('--api-log-file',), {'nargs': '?', 'const': None, 'default': False, 'help': 'log API requests to the specified file (specify option without filename to use the default location)'}], [('--utxo-locks-max-addresses',), {'type': int, 'default': config.DEFAULT_UTXO_LOCKS_MAX_ADDRESSES, 'help': 'max number of addresses for which to track UTXO locks'}], - [('--utxo-locks-max-age',), {'type': int, 'default': config.DEFAULT_UTXO_LOCKS_MAX_AGE, 'help': 'how long to keep a lock on a UTXO being tracked'}] + [('--utxo-locks-max-age',), {'type': int, 'default': config.DEFAULT_UTXO_LOCKS_MAX_AGE, 'help': 'how long to keep a lock on a UTXO being tracked'}], + [('--checkdb',), {'action': 'store_true', 'default': False, 'help': 'check the database for integrity (default: false)'}] ] class VersionError(Exception): @@ -92,6 +93,10 @@ def main(): parser_bootstrap.add_argument('-q', '--quiet', dest='quiet', action='store_true', help='suppress progress bar') #parser_bootstrap.add_argument('--branch', help='use a different branch for bootstrap db pulling') + parser_checkdb = subparsers.add_parser('checkdb', help='do an integrity check on the database') + + + args = parser.parse_args() log.set_up(log.ROOT_LOGGER, verbose=args.verbose, console_logfilter=os.environ.get('COUNTERPARTY_LOGGING', None)) @@ -118,7 +123,7 @@ def init_with_catch(fn, init_args): raise e # Configuration - COMMANDS_WITH_DB = ['reparse', 'rollback', 'kickstart', 'start', 'vacuum'] + COMMANDS_WITH_DB = ['reparse', 'rollback', 'kickstart', 'start', 'vacuum', 'checkdb'] COMMANDS_WITH_CONFIG = ['debug_config'] if args.action in COMMANDS_WITH_DB or args.action in COMMANDS_WITH_CONFIG: init_args = dict(database_file=args.database_file, @@ -143,7 +148,8 @@ def init_with_catch(fn, init_args): force=args.force, verbose=args.verbose, console_logfilter=os.environ.get('COUNTERPARTY_LOGGING', None), p2sh_dust_return_pubkey=args.p2sh_dust_return_pubkey, utxo_locks_max_addresses=args.utxo_locks_max_addresses, - utxo_locks_max_age=args.utxo_locks_max_age) + utxo_locks_max_age=args.utxo_locks_max_age, + checkdb=(args.action == 'checkdb') or (args.checkdb)) #,broadcast_tx_mainnet=args.broadcast_tx_mainnet) if args.action in COMMANDS_WITH_DB: @@ -171,6 +177,9 @@ def init_with_catch(fn, init_args): elif args.action == 'vacuum': server.vacuum(db) + elif args.action == 'checkdb': + print("Database integrity check done!") + else: parser.print_help() From 4228045ecfdad2a864c357c5eefb30febed1a7d6 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sat, 22 Oct 2022 12:46:38 -0400 Subject: [PATCH 2/2] - Tab to space --- counterpartycli/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/counterpartycli/server.py b/counterpartycli/server.py index 354f8119c0..6ea6dc285c 100755 --- a/counterpartycli/server.py +++ b/counterpartycli/server.py @@ -53,7 +53,7 @@ [('--utxo-locks-max-addresses',), {'type': int, 'default': config.DEFAULT_UTXO_LOCKS_MAX_ADDRESSES, 'help': 'max number of addresses for which to track UTXO locks'}], [('--utxo-locks-max-age',), {'type': int, 'default': config.DEFAULT_UTXO_LOCKS_MAX_AGE, 'help': 'how long to keep a lock on a UTXO being tracked'}], - [('--checkdb',), {'action': 'store_true', 'default': False, 'help': 'check the database for integrity (default: false)'}] + [('--checkdb',), {'action': 'store_true', 'default': False, 'help': 'check the database for integrity (default: false)'}] ] class VersionError(Exception):