Closed iamRuda closed 4 years ago
Hey. It has been a while since I updated this code. If Im not wrong, there is a bug that happens with certain wallet addresses. Try making another one and test again.
I don't know what i am doing wrong. Check me out: Step 1. I install "requirements.txt"; Step 2. I open "wallet.py"; Step 3. I generate new wallet with new title "wallet056594"; Step 4. I open "miner.py". Then the program throws this error; I have Windows 7 x64 and Python 3.7. Тhank you in advance and Sorry to trouble you.
Try doing a fast test. Run the code again but without changing the miner_config.py
file. Check if that way it still crashes.
I don't have the laptop with me so I can't test it.
I always get the exactly the same error at the beginning of the program. Maybe I'm doing it wrong, since I'm usualy programming in C++. And There's no rush. ^_^
Sorry, question is still going. :-/
Just tested. Mine is working. Let me see if I can guess what's your error.
@RudFireMan go to miner_config.py
and change your miner address to "asd"
. Run again.
miner.py
and comment 2 lines that start with p1 =
and p1.start()
. Line 265
and 266
. Run again and see if it crash.Wow! When I write in "miner_config.py" asd and run "miner.py", I see it and I do not know what is this.
It was probably due to your address having non utf characters. Each of those thing you see is a block, which may contain several transactions. So you are mining and adding a new block to the blockchain. Everytime a new block is added, the proof of work gets harder and slower to solve.
I think that solves your problem. I should fix the bug though.
What you need me to do?
Can I work on this issue?
Of course. Just make sure the changes are simple. We must keep it as much newbie friendly as we can, so avoid using external libraries.
Sure, thanks! Do you have any ideia about the bug?
Yes, apparently, when you generate a new address, it has some non utf-8 characters that make the code crash. So you should try to reproduce the error, learn what kind of characters are making the code crash and then we can think a solution.
Good luck!
I am trying to replicate the error but still no luck. With "generate a new address" you mean run wallet.py and select the "generate new wallet" option? I have already tried the following:
If I paste an address like this KovGGg/F8jSP+V4YiQT+qgEx4nDK95e/Kl29BIo63+epTfQp9wEgyrDOfAp83deO8EPkE0vwh0mQoLR0mboKvQ==
in the config file, the code crash. Meanwhile an adress like this: q3nf394hjg-random-miner-address-34nf3i4nflkn3oi
works as expected.
Found the problem. In the code snippet bellow the GET request is made by concatenating the URL with the update parameter. https://github.com/cosme12/SimpleCoin/blob/8da677ae42041ad1bf66b0756424b782283bbbc0/simpleCoin/miner.py#L110-L112
So when you used an URL reserved character in the MINER_ADDRESS variable, like "+", "&" or "=", the request was badly processed by the transaction function GET part bellow: https://github.com/cosme12/SimpleCoin/blob/8da677ae42041ad1bf66b0756424b782283bbbc0/simpleCoin/miner.py#L230-L234
So request.args.get("update") == MINER_ADDRESS would not be true and the request would return a 500 code and then the json.loads would fail as the response was empty, raising an error.
So MINER_ADDRESS like: q3nf394hjg-ra#ndom-miner-address-34nf3i4nflkn3oi q3nf394hjg-ra&ndom-miner-address-34nf3i4nflkn3oi q3nf394hjg-ra+ndom-miner-address-34nf3i4nflkn3oi q3nf394hjg-ra=ndom-miner-address-34nf3i4nflkn3oi
Would make the code crash.
I am submiting a PR with the fix at this moment, tell what you think. Thank you!
Awesome. Tested and working! Thanks @elijose55
Help me! I run in cmd.![55556](https://user-images.githubusercontent.com/58519745/70151780-18449800-16bd-11ea-9327-987abb1b384d.PNG)