Skip to content
Snippets Groups Projects
Unverified Commit 39d05af4 authored by Benjamin Loison's avatar Benjamin Loison
Browse files

Simplify `U` by removing `{lower,upper}Bound` parameters

parent 1acf798e
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,7 @@ import math
# bits_to_target(int(headers[0]['bits'], 16))
genesisTarget = 26959535291011309493156476344723991336010898738574164086137773096960
IS_EPSILON_TARGET_DEFINITION = True
# Could be determined thanks to `sys.argv[0]` but I'm unsure what is our statement concerning running in an IDE such as Pyzo or if it would work fine on Windows (notably due to the possible `./` prefix).
MINING_IN_LOGARITHMIC_SPACE_CONSTANT_DIFFICULTY_LEVEL = True
MINING_IN_LOGARITHMIC_SPACE_CONSTANT_DIFFICULTY_LEVEL = False
class Block:
# `target` and `_hash` are `int`s.
......
......@@ -44,7 +44,7 @@ def Dissolve(m, k, C, previous_score, previous_ℓ):
def Compress(m, k, C, previous_score, previous_ℓ):
(D, , χ, new_score) = Dissolve(m, k, C, previous_score, previous_ℓ)
π = U(0, , D)
π = U(D)
return π + χ, new_score,
def uparrow(C, μ):
......@@ -93,9 +93,9 @@ def llbracket(C, μ, CIndex, actually = False):
def score(C, ):
return sum([(min(block.level, ) + 1 - block.level_min) * block.score for block in C])
def U(lowerBound, upperBound, chains):
def U(chains):
chains = [chains[μ] for μ in chains]
flattened_chain = [block for chain in chains[lowerBound:upperBound+1] for block in chain]
flattened_chain = [block for chain in chains for block in chain]
unique_blocks = {}
for block in flattened_chain:
if not block.height in unique_blocks or block.level_min < unique_blocks[block.height].level_min:
......
......@@ -21,7 +21,7 @@ def Dissolve(m, k, C, previous_score, previous_ℓ):
CStarμ = uparrow(CStar, μ)
CStarμSinceb = [block for block in CStarμ if block.height >= b.height]
chains = {chainsIndex: chain for chainsIndex, chain in enumerate([CStarμ[-2 * m:], CStarμSinceb])}
D[μ] = U(0, 1, chains)
D[μ] = U(chains)
previousCStarμ = CStarμ
else:
= 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment