lhartikk / naivecoin

A tutorial for building a cryptocurrency

Home Page:https://lhartikk.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sankycui opened this issue · comments

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;
};