Skip to content

Commit

Permalink
On minor version change, reparse from a given block if required
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Mar 18, 2024
1 parent b765df6 commit 20f0f63
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions counterparty-lib/counterpartylib/lib/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning

Code scanning / pylint

Attempting to unpack a non-sequence defined at line 25 of counterpartylib.lib.config. Warning

Attempting to unpack a non-sequence defined at line 25 of counterpartylib.lib.config.
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
)
6 changes: 6 additions & 0 deletions counterparty-lib/counterpartylib/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 20f0f63

Please sign in to comment.