Savjee / SavjeeCoin

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

remove unnecessary function #24

Closed hasezoey closed 5 years ago

hasezoey commented 5 years ago

i couldnt think of any instance where "currentBlock.calculateHash" wouldnt fail and "previousBlock.calculateHash" would go in -> i could be wrong, just wanting to point this out (and when this and #23 the coverage would go up to nearly 100%)

hasezoey commented 5 years ago

-> i know that the check failed, i will fix it, when i get confirmation that it is not necessary

Savjee commented 5 years ago

Why are you removing this check? It's possible that someone tried to tamper with a block by changing the hash.

hasezoey commented 5 years ago

because when trying to tamper with the current & previous hash(or anything else in the currentBlock) wouldnt it be already be catched by if (currentBlock.hash !== currentBlock.calculateHash()) or am i just thinking wrong on this?

Edit: i mean like, i cant think of any case where it will not be catched already

Savjee commented 5 years ago

Ah, yes! You're absolutely right, because the previousHash is included when calculating the hash!