PythonBitcoinMiner icon indicating copy to clipboard operation
PythonBitcoinMiner copied to clipboard

Handle subscribe response errors on json parsing

Open urban-ape opened this issue 2 years ago • 3 comments

When setting up a connection to the ckpool server and sending a handle subscribe message, there is an error that indicates the response contains more than one JSON object or extraneous data at the end. When there is more than one JSON object or extraneous data in the response, the Python loads() method will fail with a JSONDecoder error containing the string "Extra data".

Python library decoder.py error with "Extra data" thrown on line 347 here: https://github.com/python/cpython/blob/main/Lib/json/decoder.py

Stacktrace example:

Traceback (most recent call last): File "/Users/user/Documents/SOLO_MINER/PythonBitcoinMiner/SoloMiner.py", line 500, in thread_new_block ret = block_listener(self) ^^^^^^^^^^^^^^^^^^^^ File "/Users/user/Documents/SOLO_MINER/PythonBitcoinMiner/SoloMiner.py", line 446, in block_listener responses = [json.loads(res) for res in response.decode().split('\n') if ^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/decoder.py", line 340, in decode raise JSONDecodeError("Extra data", s, end) json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

urban-ape avatar Oct 17 '24 18:10 urban-ape

I was going to submit a fix for this, but since you closed this with no discussion then I'll just let everyone who uses your repo continue to get errors and potentially mine on an outdated block template. Well done.

urban-ape avatar Nov 12 '24 16:11 urban-ape

I was going to submit a fix for this, but since you closed this with no discussion then I'll just let everyone who uses your repo continue to get errors and potentially mine on an outdated block template. Well done.

Sorry about that.Recently I was really busy and out of time to deal with the bug.But if you still want to contribute,you can still pull request and I will accept that after check

HugoXOX3 avatar Nov 14 '24 13:11 HugoXOX3

All Bug are fixed at Beta Version v2.0.0

HugoXOX3 avatar Dec 28 '24 16:12 HugoXOX3