From 20f0f635f80d6f8fa459c31e0f85f26e2abd964b Mon Sep 17 00:00:00 2001 From: Ouziel Slama Date: Mon, 18 Mar 2024 12:39:33 +0100 Subject: [PATCH] On minor version change, reparse from a given block if required --- counterparty-lib/counterpartylib/lib/check.py | 15 ++++++++++++--- counterparty-lib/counterpartylib/lib/config.py | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/counterparty-lib/counterpartylib/lib/check.py b/counterparty-lib/counterpartylib/lib/check.py index af4a39c5e6..6880c9fdd2 100644 --- a/counterparty-lib/counterpartylib/lib/check.py +++ b/counterparty-lib/counterpartylib/lib/check.py @@ -364,7 +364,16 @@ def database_version(db): ) elif version_minor != config.VERSION_MINOR: # Reparse transactions from the vesion block if minor version has changed. + message = f'Client minor version number mismatch ({version_minor} ≠ {config.VERSION_MINOR}).' + if config.NEED_REPARSE_IF_MINOR_IS_LESS_THAN is not None: + min_version_minor, min_version_block_index = config.NEED_REPARSE_IF_MINOR_IS_LESS_THAN + if version_minor < min_version_minor: + raise DatabaseVersionError( + message=message, + required_action='reparse', + from_block_index=min_version_block_index + ) raise DatabaseVersionError( - message=f'Client minor version number mismatch ({version_minor} ≠ {config.VERSION_MINOR}).', - required_action='reparse', - from_block_index=config.BLOCK_FIRST) + message=message, + required_action=None + ) diff --git a/counterparty-lib/counterpartylib/lib/config.py b/counterparty-lib/counterpartylib/lib/config.py index 6201f29ef1..3285d89e9c 100644 --- a/counterparty-lib/counterpartylib/lib/config.py +++ b/counterparty-lib/counterpartylib/lib/config.py @@ -17,6 +17,12 @@ ADDRINDEXRS_VERSION = "0.4.3" +# When updating to a new verion, we are making a rollback if major version changes. +# If minor version changes and if needed, we are making a reparse from a given block. +# Fo example: +# NEED_REPARSE_IF_MINOR_IS_LESS_THAN = (1, 800000) +# means that we need to reparse from block 800000 if database minor version is less than 1 +NEED_REPARSE_IF_MINOR_IS_LESS_THAN = None # Counterparty protocol TXTYPE_FORMAT = '>I'