lhartikk / naivecoin

A tutorial for building a cryptocurrency
https://lhartikk.github.io/
Apache License 2.0
531 stars 266 forks source link

A bug at line 209 of the blockchain.ts , must return false #18

Open sankycui opened 4 years ago

sankycui commented 4 years ago

look at the location : //must return false return false;


const hasValidHash = (block: Block): boolean => {

    if (!hashMatchesBlockContent(block)) {
        console.log('invalid hash, got:' + block.hash);
        return false;
    }

    if (!hashMatchesDifficulty(block.hash, block.difficulty)) {
        console.log('block difficulty not satisfied. Expected: ' + block.difficulty + 'got: ' + block.hash);
        //must return false
        return false;
 }
    return true;
};