async mineBlock( block,  difficulty, start, end, height, showLogsOnlyOnce){

        if(showLogsOnlyOnce) {
            console.log("");
            console.log(" ----------- mineBlock-------------", height, "  ", difficulty.toString("hex"));
        }

        try{

            //calculating the hashes per second


            let answer;

            try {
                answer = await this.mine(block, difficulty, start, end, height);
            } catch (exception){
                console.error("Couldn't mine block " + block.height, exception);
                answer = {
                    result: false,
                };
            }

            if (answer && answer.result && this.blockchain.blocks.length === block.height ){

                console.warn( "----------------------------------------------------------------------------");
                console.warn( "WebDollar Block was mined ", block.height ," nonce (", answer.nonce+")", "timestamp", block.timeStamp, answer.hash.toString("hex"), " reward", (block.reward / WebDollarCoins.WEBD), "WEBD", block.data.minerAddress.toString("hex"));
                console.warn( "difficulty prev: ", block.difficultyTargetPrev.toString("hex") );
                console.warn( "----------------------------------------------------------------------------");

                //check if I mined all the last K blocks
                let i = this.blockchain.blocks.length-1;
                let count = 0;

                while ( !consts.DEBUG && i >= 0 && this.blockchain.blocks[i].data.minerAddress.equals( this.unencodedMinerAddress ) ){

                    count ++;
                    i--;

                    if (count >= consts.MINING_POOL.MINING.MAXIMUM_BLOCKS_TO_MINE_BEFORE_ERROR){

                        StatusEvents.emit("blockchain/logs", {message: "You mined way too many blocks"});
                        break;
                    }

                }

                let revertActions = new RevertActions(this.blockchain);

                try {

                    if (await this.blockchain.semaphoreProcessing.processSempahoreCallback( async () => {

                            block.hash = answer.hash;
                            block.nonce = answer.nonce;

                            //returning false, because a new fork was changed in the mean while
                            if (this.blockchain.blocks.length !== block.height)
                                return false;

                            return this.blockchain.includeBlockchainBlock( block, false, ["all"], true, revertActions, false );

                        }) === false) throw {message: "Mining2 returned false"};

                    NodeBlockchainPropagation.propagateLastBlockFast( block );

                    //confirming transactions
                    block.data.transactions.confirmTransactions();

                    StatusEvents.emit("blockchain/new-blocks", { });

                } catch (exception){
                    console.error("Mining processBlocksSempahoreCallback raised an error ",block.height, exception);
                    revertActions.revertOperations();
                }
                revertActions.destroyRevertActions();

            } else
            if (!answer.result)
                if(showLogsOnlyOnce)
                    console.error( "block ", block.height ," was not mined...");

            if (this.reset) { // it was reset
                this.reset = false;
                this._hashesPerSecond = 0;
            }

        } catch (Exception){

            console.error( "Error mining block ", Exception, (block !== null ? block.toJSON() : '') );

            throw Exception;
        }

    }
/**
     * Mine a specific Block
     * @param block
     * @param difficulty
     */
Mine a specific Block
@param block
@param difficulty
Mine a specific Block @param block @param difficulty
async mineBlock( block,  difficulty, start, end, height, showLogsOnlyOnce){
        if(showLogsOnlyOnce) {
            console.log("");
            console.log(" ----------- mineBlock-------------", height, "  ", difficulty.toString("hex"));
        }
        try{
            let answer;
            try {
                answer = await this.mine(block, difficulty, start, end, height);
            } catch (exception){
                console.error("Couldn't mine block " + block.height, exception);
                answer = {
                    result: false,
                };
            }
            if (answer && answer.result && this.blockchain.blocks.length === block.height ){
                console.warn( "----------------------------------------------------------------------------");
                console.warn( "WebDollar Block was mined ", block.height ," nonce (", answer.nonce+")", "timestamp", block.timeStamp, answer.hash.toString("hex"), " reward", (block.reward / WebDollarCoins.WEBD), "WEBD", block.data.minerAddress.toString("hex"));
                console.warn( "difficulty prev: ", block.difficultyTargetPrev.toString("hex") );
                console.warn( "----------------------------------------------------------------------------");
                let i = this.blockchain.blocks.length-1;
                let count = 0;
                while ( !consts.DEBUG && i >= 0 && this.blockchain.blocks[i].data.minerAddress.equals( this.unencodedMinerAddress ) ){
                    count ++;
                    i--;
                    if (count >= consts.MINING_POOL.MINING.MAXIMUM_BLOCKS_TO_MINE_BEFORE_ERROR){
                        StatusEvents.emit("blockchain/logs", {message: "You mined way too many blocks"});
                        break;
                    }
                }
                let revertActions = new RevertActions(this.blockchain);
                try {
                    if (await this.blockchain.semaphoreProcessing.processSempahoreCallback( async () => {
                            block.hash = answer.hash;
                            block.nonce = answer.nonce;
                            if (this.blockchain.blocks.length !== block.height)
                                return false;
                            return this.blockchain.includeBlockchainBlock( block, false, ["all"], true, revertActions, false );
                        }) === false) throw {message: "Mining2 returned false"};
                    NodeBlockchainPropagation.propagateLastBlockFast( block );
                    block.data.transactions.confirmTransactions();
                    StatusEvents.emit("blockchain/new-blocks", { });
                } catch (exception){
                    console.error("Mining processBlocksSempahoreCallback raised an error ",block.height, exception);
                    revertActions.revertOperations();
                }
                revertActions.destroyRevertActions();
            } else
            if (!answer.result)
                if(showLogsOnlyOnce)
                    console.error( "block ", block.height ," was not mined...");
            if (this.reset) { 
                this.reset = false;
                this._hashesPerSecond = 0;
            }
        } catch (Exception){
            console.error( "Error mining block ", Exception, (block !== null ? block.toJSON() : '') );
            throw Exception;
        }
    }
async mineBlock ( block , difficulty , start , end , height , showLogsOnlyOnce ) { if ( showLogsOnlyOnce ) { console . log ( "" ) ; console . log ( " ----------- mineBlock-------------" , height , "  " , difficulty . toString ( "hex" ) ) ; } try { let answer ; try { answer = await this . mine ( block , difficulty , start , end , height ) ; } catch ( exception ) { console . error ( "Couldn't mine block " + block . height , exception ) ; answer = { result : false , } ; } if ( answer && answer . result && this . blockchain . blocks . length === block . height ) { console . warn ( "----------------------------------------------------------------------------" ) ; console . warn ( "WebDollar Block was mined " , block . height , " nonce (" , answer . nonce + ")" , "timestamp" , block . timeStamp , answer . hash . toString ( "hex" ) , " reward" , ( block . reward / WebDollarCoins . WEBD ) , "WEBD" , block . data . minerAddress . toString ( "hex" ) ) ; console . warn ( "difficulty prev: " , block . difficultyTargetPrev . toString ( "hex" ) ) ; console . warn ( "----------------------------------------------------------------------------" ) ; let i = this . blockchain . blocks . length - 1 ; let count = 0 ; while ( ! consts . DEBUG && i >= 0 && this . blockchain . blocks [ i ] . data . minerAddress . equals ( this . unencodedMinerAddress ) ) { count ++ ; i -- ; if ( count >= consts . MINING_POOL . MINING . MAXIMUM_BLOCKS_TO_MINE_BEFORE_ERROR ) { StatusEvents . emit ( "blockchain/logs" , { message : "You mined way too many blocks" } ) ; break ; } } let revertActions = new RevertActions ( this . blockchain ) ; try { if ( await this . blockchain . semaphoreProcessing . processSempahoreCallback ( async ( ) => { block . hash = answer . hash ; block . nonce = answer . nonce ; if ( this . blockchain . blocks . length !== block . height ) return false ; return this . blockchain . includeBlockchainBlock ( block , false , [ "all" ] , true , revertActions , false ) ; } ) === false ) throw { message : "Mining2 returned false" } ; NodeBlockchainPropagation . propagateLastBlockFast ( block ) ; block . data . transactions . confirmTransactions ( ) ; StatusEvents . emit ( "blockchain/new-blocks" , { } ) ; } catch ( exception ) { console . error ( "Mining processBlocksSempahoreCallback raised an error " , block . height , exception ) ; revertActions . revertOperations ( ) ; } revertActions . destroyRevertActions ( ) ; } else if ( ! answer . result ) if ( showLogsOnlyOnce ) console . error ( "block " , block . height , " was not mined..." ) ; if ( this . reset ) { this . reset = false ; this . _hashesPerSecond = 0 ; } } catch ( Exception ) { console . error ( "Error mining block " , Exception , ( block !== null ? block . toJSON ( ) : '' ) ) ; throw Exception ; } }
Mine a specific Block
 @param block
 @param difficulty
Mine a specific Block @param block @param difficulty
//calculating the hashes per second //check if I mined all the last K blocks //returning false, because a new fork was changed in the mean while //confirming transactions // it was reset