Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maximum recursion depth exceeded #25

Closed
ghost opened this issue Apr 10, 2023 · 2 comments
Closed

maximum recursion depth exceeded #25

ghost opened this issue Apr 10, 2023 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 10, 2023

File "blockchain-parser.py", line 30, in merkle_root
return merkle_root([hash_pair(x,y) for x, y in zip(*[iter(lst)]*2)])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object

using python 3.11.3

sys.setrecursionlimit(num) crashes windows before completing a block transformation

@NewJerseyStyle
Copy link

NewJerseyStyle commented Jan 3, 2024

Same problem, solved by modifying recursive function merkle_root to while-loop

def merkle_root(lst):
    sha256d = lambda x: hashlib.sha256(hashlib.sha256(x).digest()).digest()
    hash_pair = lambda x, y: sha256d(x[::-1] + y[::-1])[::-1]
    while len(lst) != 1:
        if len(lst) % 2 == 1:
            lst.append(lst[-1])
        lst = [hash_pair(x,y) for x, y in zip(*[iter(lst)]*2)]
    return lst[0]

Now it is a dead loop...

@ragestack
Copy link
Owner

I think it is because the dat fil corrupted or you trying to parse any altcoin without some tricks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants