Blockchain/Bitcoin/build-blockchain-from-scratch/sf-chain/blockchain/block.js
// current block data, nonce, adjusted difficulty
current block data, nonce, adjusted difficulty
current block data nonce adjusted difficulty
static mineBlock(lastBlock, data) {
        const lastHash = lastBlock.hash;
        let hash, timestamp;
        let nonce = 0;
        let { difficulty } = lastBlock;
        timestamp = Date.now();
        do {
            nonce++;
            timestamp = Date.now()
            difficulty = Block.adjustDifficulty(lastBlock, timestamp);
            hash = Block.hash(timestamp, lastHash, data, nonce, difficulty);
        } while (hash.substring(0, difficulty) !== '0'.repeat(difficulty));
        return new this(timestamp, lastHash, hash, data, nonce, difficulty);
    }
static mineBlock ( lastBlock , data ) { const lastHash = lastBlock . hash ; let hash , timestamp ; let nonce = 0 ; let { difficulty } = lastBlock ; timestamp = Date . now ( ) ; do { nonce ++ ; timestamp = Date . now ( ) difficulty = Block . adjustDifficulty ( lastBlock , timestamp ) ; hash = Block . hash ( timestamp , lastHash , data , nonce , difficulty ) ; } while ( hash . substring ( 0 , difficulty ) !== '0' . repeat ( difficulty ) ) ; return new this ( timestamp , lastHash , hash , data , nonce , difficulty ) ; }
current block data, nonce, adjusted difficulty
current block data nonce adjusted difficulty
// get new hash from timestamp, lash block hash, current block data // nonce, difficulty