Skip to content

Commit

Permalink
binds the 'addrindexrs' version to the 'counterparty-core' version
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Mar 14, 2024
1 parent f019617 commit 7786792
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
12 changes: 6 additions & 6 deletions counterparty-lib/counterpartylib/lib/backend/addrindexrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import bitcoin.wallet
from pkg_resources import parse_version

from counterpartylib.lib import config, util, ledger
from counterpartylib.lib import config, util, ledger, exceptions

logger = logging.getLogger(config.LOGGER_NAME)

Expand Down Expand Up @@ -397,14 +397,14 @@ def indexer_check_version():
except TypeError as e:
logger.exception(f'Error when checking address indexer version: {addrindexrs_version}')
sys.exit(1)
addrindexrs_version_needed = ledger.get_value_by_block_index("addrindexrs_required_version")

if parse_version(addrindexrs_version_needed) > parse_version(addrindexrs_version_label):
logger.info("Wrong addrindexrs version: "+addrindexrs_version_needed+" is needed but "+addrindexrs_version_label+" was found")
if addrindexrs_version_label != config.ADDRINDEXRS_VERSION:

Check warning

Code scanning / pylint

Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it. Warning

Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it.
message = f"Wrong addrindexrs version: {config.ADDRINDEXRS_VERSION} is needed but {addrindexrs_version_label} was found"
#logger.error(message)
INDEXER_THREAD.stop()
sys.exit(config.EXITCODE_UPDATE_REQUIRED)
raise exceptions.InvalidVersion(message)
else:
logger.debug(f'Version check of address indexer passed ({addrindexrs_version_label} > {addrindexrs_version_needed}).')
logger.debug(f'Version check of address indexer passed ({config.ADDRINDEXRS_VERSION} == {addrindexrs_version_label}).')

def _script_pubkey_to_hash(spk):
return hashlib.sha256(spk).digest()[::-1].hex()
Expand Down
2 changes: 2 additions & 0 deletions counterparty-lib/counterpartylib/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
VERSION_REVISION = int(version[2])
VERSION_PRE_RELEASE = '-'.join(VERSION_STRING.split('-')[1:])

ADDRINDEXRS_VERSION = "0.4.3"


# Counterparty protocol
TXTYPE_FORMAT = '>I'
Expand Down
4 changes: 4 additions & 0 deletions counterparty-lib/counterpartylib/lib/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ class UnknownTable(Exception):
class UnknownField(Exception):
pass

class InvalidVersion(Exception):
pass


# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
19 changes: 0 additions & 19 deletions counterparty-lib/counterpartylib/protocol_changes.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,25 +459,6 @@
"block_index": 819300,
"testnet_block_index": 2505725
},
"addrindexrs_required_version": {
"minimum_version_major": 0,
"mainnet":{
"0":{
"value":"0.4.0"
},
"819300":{
"value":"0.4.1"
}
},
"testnet":{
"0":{
"value":"0.4.0"
},
"2505725":{
"value":"0.4.1"
}
}
},
"max_dispenses_limit": {
"minimum_version_major": 0,
"mainnet":{
Expand Down

0 comments on commit 7786792

Please sign in to comment.