src/block.c
bool is_signed(const Block *b, const uint8_t *difficulty)
{
    uint8_t byte;
    uint8_t bit_counter = 0;
    for (uint8_t i = 0; i < SHA256_BLOCK_SIZE; i++)
    {
        byte = b->hash[i];

        /* read 8 bits of current byte */
        for (uint8_t bit_idx = 0; bit_idx < 8; bit_idx++)
        {
            if (byte & 0b10000000) /* check if first bit of the byte is 1 */
                return false;

            bit_counter++;
            if (bit_counter == *difficulty)
                return true;

            byte <<= 1; /* left shift one bit to the left */
        }
    }

    return true;
}
/* check if the block's hash starts with "difficulty" number of zero-bits */
check if the block's hash starts with "difficulty" number of zero-bits
check if the block ' s hash starts with " difficulty " number of zero - bits
bool is_signed(const Block *b, const uint8_t *difficulty)
{
    uint8_t byte;
    uint8_t bit_counter = 0;
    for (uint8_t i = 0; i < SHA256_BLOCK_SIZE; i++)
    {
        byte = b->hash[i];
        for (uint8_t bit_idx = 0; bit_idx < 8; bit_idx++)
        {
            if (byte & 0b10000000) 
                return false;
            bit_counter++;
            if (bit_counter == *difficulty)
                return true;
            byte <<= 1; 
        }
    }
    return true;
}
bool is_signed ( const Block * b , const uint8_t * difficulty ) { uint8_t byte ; uint8_t bit_counter = 0 ; for ( uint8_t i = 0 ; i < SHA256_BLOCK_SIZE ; i ++ ) { byte = b -> hash [ i ] ; for ( uint8_t bit_idx = 0 ; bit_idx < 8 ; bit_idx ++ ) { if ( byte & 0b10000000 ) return false ; bit_counter ++ ; if ( bit_counter == * difficulty ) return true ; byte <<= 1 ; } } return true ; }
check if the block's hash starts with "difficulty" number of zero-bits
check if the block ' s hash starts with " difficulty " number of zero - bits
/* read 8 bits of current byte */ /* check if first bit of the byte is 1 */ /* left shift one bit to the left */