src/blockchain.c
void bchain_add_block(
    Blockchain *bchain, Transaction txs[NUM_TRANSACTIONS])
{
    if (bchain->size >= NUM_BLOCKS)
    {
        fprintf(stderr, "can't add block: blockchain is full\n");
        exit(EXIT_FAILURE);
    }

    /* create the new block */
    Block *new_block = block_new(
        bchain->size,
        bchain_latest(bchain)->hash,
        txs);

    /* mine the block */
    block_mine(new_block, bchain->difficulty);

    /* set the right block in the array */
    bchain->blocks[bchain->size] = new_block;
    bchain->size++;
}
/* add a block to the blockchain with the given data */
add a block to the blockchain with the given data
add a block to the blockchain with the given data
void bchain_add_block(
    Blockchain *bchain, Transaction txs[NUM_TRANSACTIONS])
{
    if (bchain->size >= NUM_BLOCKS)
    {
        fprintf(stderr, "can't add block: blockchain is full\n");
        exit(EXIT_FAILURE);
    }
    Block *new_block = block_new(
        bchain->size,
        bchain_latest(bchain)->hash,
        txs);
    block_mine(new_block, bchain->difficulty);
    bchain->blocks[bchain->size] = new_block;
    bchain->size++;
}
void bchain_add_block ( Blockchain * bchain , Transaction txs [ NUM_TRANSACTIONS ] ) { if ( bchain -> size >= NUM_BLOCKS ) { fprintf ( stderr , " \n " ) ; exit ( EXIT_FAILURE ) ; } Block * new_block = block_new ( bchain -> size , bchain_latest ( bchain ) -> hash , txs ) ; block_mine ( new_block , bchain -> difficulty ) ; bchain -> blocks [ bchain -> size ] = new_block ; bchain -> size ++ ; }
add a block to the blockchain with the given data
add a block to the blockchain with the given data
/* create the new block */ /* mine the block */ /* set the right block in the array */