From 6aa124592d0f6add6a50f469c01c0a9ed33c56b9 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 20 May 2021 12:54:13 -0400 Subject: [PATCH] move get_expiration_height and claimtrie constants to Coin class --- lbry/wallet/server/coin.py | 31 ++++++++++++++++++++++++++++++ lbry/wallet/server/db/claimtrie.py | 16 --------------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/lbry/wallet/server/coin.py b/lbry/wallet/server/coin.py index 569cd50bd..deef80450 100644 --- a/lbry/wallet/server/coin.py +++ b/lbry/wallet/server/coin.py @@ -261,6 +261,18 @@ class LBC(Coin): TX_PER_BLOCK = 1 RPC_PORT = 9245 REORG_LIMIT = 200 + + nOriginalClaimExpirationTime = 262974 + nExtendedClaimExpirationTime = 2102400 + nExtendedClaimExpirationForkHeight = 400155 + nNormalizedNameForkHeight = 539940 # targeting 21 March 2019 + nMinTakeoverWorkaroundHeight = 496850 + nMaxTakeoverWorkaroundHeight = 658300 # targeting 30 Oct 2019 + nWitnessForkHeight = 680770 # targeting 11 Dec 2019 + nAllClaimsInMerkleForkHeight = 658310 # targeting 30 Oct 2019 + proportionalDelayFactor = 32 + maxTakeoverDelay = 4032 + PEERS = [ ] @@ -338,6 +350,16 @@ class LBC(Coin): else: return sha256(script).digest()[:HASHX_LEN] + @classmethod + def get_expiration_height(cls, last_updated_height: int) -> int: + if last_updated_height < cls.nExtendedClaimExpirationForkHeight: + return last_updated_height + cls.nOriginalClaimExpirationTime + return last_updated_height + cls.nExtendedClaimExpirationTime + + @classmethod + def get_delay_for_name(cls, blocks_of_continuous_ownership: int) -> int: + return min(blocks_of_continuous_ownership // cls.proportionalDelayFactor, cls.maxTakeoverDelay) + class LBCRegTest(LBC): NET = "regtest" @@ -347,6 +369,15 @@ class LBCRegTest(LBC): P2PKH_VERBYTE = bytes.fromhex("6f") P2SH_VERBYTES = bytes.fromhex("c4") + nOriginalClaimExpirationTime = 500 + nExtendedClaimExpirationTime = 600 + nExtendedClaimExpirationForkHeight = 800 + nNormalizedNameForkHeight = 250 + nMinTakeoverWorkaroundHeight = -1 + nMaxTakeoverWorkaroundHeight = -1 + nWitnessForkHeight = 150 + nAllClaimsInMerkleForkHeight = 350 + class LBCTestNet(LBCRegTest): NET = "testnet" diff --git a/lbry/wallet/server/db/claimtrie.py b/lbry/wallet/server/db/claimtrie.py index 9bc02a895..2634ed595 100644 --- a/lbry/wallet/server/db/claimtrie.py +++ b/lbry/wallet/server/db/claimtrie.py @@ -4,26 +4,10 @@ from lbry.wallet.server.db.revertable import RevertablePut, RevertableDelete, Re from lbry.wallet.server.db import DB_PREFIXES from lbry.wallet.server.db.prefixes import Prefixes, ClaimTakeoverValue -nOriginalClaimExpirationTime = 262974 -nExtendedClaimExpirationTime = 2102400 -nExtendedClaimExpirationForkHeight = 400155 -nNormalizedNameForkHeight = 539940 # targeting 21 March 2019 -nMinTakeoverWorkaroundHeight = 496850 -nMaxTakeoverWorkaroundHeight = 658300 # targeting 30 Oct 2019 -nWitnessForkHeight = 680770 # targeting 11 Dec 2019 -nAllClaimsInMerkleForkHeight = 658310 # targeting 30 Oct 2019 -proportionalDelayFactor = 32 -maxTakeoverDelay = 4032 -def get_delay_for_name(blocks_of_continuous_ownership: int) -> int: - return min(blocks_of_continuous_ownership // proportionalDelayFactor, maxTakeoverDelay) -def get_expiration_height(last_updated_height: int) -> int: - if last_updated_height < nExtendedClaimExpirationForkHeight: - return last_updated_height + nOriginalClaimExpirationTime - return last_updated_height + nExtendedClaimExpirationTime def length_encoded_name(name: str) -> bytes: