Skip to content

Commit

Permalink
Merge pull request #128 from pataegrillo/master
Browse files Browse the repository at this point in the history
- Adding checkdb as a new parameter that will be used by counterparty to perform a database integrity check
  • Loading branch information
jdogresorg authored Nov 29, 2022
2 parents d54e098 + 4228045 commit 0f7a0a2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions counterpartycli/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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))
Expand All @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 0f7a0a2

Please sign in to comment.