Savjee / SavjeeCoin

A simple blockchain in Javascript. For educational purposes only.
MIT License
1.74k stars 752 forks source link

Is chain valid? false #55

Closed ghost closed 2 years ago

ghost commented 2 years ago

After I tried to see if my block was valid but no matter what I did, it still said that it was not valid. I put my code below. Blockchain.js:

Screen Shot 2022-01-18 at 2 46 10 PM Screen Shot 2022-01-18 at 2 46 21 PM Screen Shot 2022-01-18 at 2 46 30 PM Screen Shot 2022-01-18 at 2 46 41 PM Screen Shot 2022-01-18 at 2 46 48 PM

Main.js:

Screen Shot 2022-01-18 at 2 50 20 PM

Keygenerator.js:

Screen Shot 2022-01-18 at 2 50 31 PM

Hopefully, someone can help me.

Savjee commented 2 years ago

Hi,

Did you write the code yourself or did you clone this repository? I can't replicate this issue with the code in this repo.

ange47rm commented 2 years ago

Hi,

I had the same issue. I found my isChainValid() method was slightly different from the one in this repo. Once I copied isChainValid() from this repo, the issue was fixed. Also make sure that in minePendingTransactions(), when you create the new Block, it adds a hash value to it.

Savjee commented 2 years ago

Thanks for letting us know! Closing this issue for now.