fix stratum parsing not always counting rejected shares #163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that IMHO the code was not always counting rejected shares correctly; at least when using public-pool.io.
The UI was always reporting 0 rejected shares even when shares got rejected (as per the log)
I noticed public-pool is responding to an accepted share with something like:
{"id":803,"error":null,"result":true}
and a response to a rejected share is something like:
{"id":873,"result":null,"error":[21,"Job not found",""]}
Reading the code, it seems it was expected to get "result":false in case of rejected shares. However as per https://braiins.com/stratum-v1/docs is seems be normal for the protocol to response with "result":null instead of "result":false for an error.
This PR change the code to simply increase the counter of rejected shares whenever the value of "error:" is not null. It also add some logging for some unhandled stratum messages (like unhandled methods and result parsing).
In order to not confuse users with high numbers of rejected shares it might be a good idea to show just "x percent rejected" instead of the actual number.