# Could make a single function iterating on `CStar` filling a dict with keys being levels and values being the number of blocks of the associated level and stop once a level value as reached a given number of blocks.
if (IS_EPSILON_TARGET_DEFINITIONand(previous_score-CStarScore)>=sanityTargetDifferenceThreshold)or(notIS_EPSILON_TARGET_DEFINITIONandCStarScore<previous_score):
# For instance for the first 60 000 blocks, we have in theory 10 levels for the last blocks while log2(256) = 8, so because of first blocks not having a higher than 8 level, it doesn't seem worth it at the beginning at least.
defgetℓ(C,previous_ℓ):
previous_ℓ+=1
# Can't use `[0] * previous_ℓ`, as would have to check if the array is long enough below before updating its values.
blocksPerLevel=[0]*κ
forblockinC:
forlevelinrange(previous_ℓ,block.level+1):
blocksPerLevel[level]+=1
forlevelinrange(previous_ℓ,κ):
ifblocksPerLevel[level]<2*m:
returnlevel-1
defllbracket(C,μ,CIndex,actually=False):
removed=False
block=C[CIndex]
ifblock.level==μ:
ifactually:
debug('removing',block.height)
delC[CIndex]
removed=True
else:
ifactually:
debug(f'increasing {block.height} level_min from {block.level_min} to {μ+1}')
debug(bcolors.WARNING+f'μ: {μ}'+bcolors.ENDC+f', len(Π): {len(Π)}, '+bcolors.OKGREEN+f'len(D[μ]): {len(D[μ])}'+bcolors.ENDC+f' ({[f"{b.height}({b.level_min}-{b.level},{round(b.score,4)})" for b in D[μ]]})')