OlinCoin
Test
create_block.h
Go to the documentation of this file.
1
11#pragma once
12#include "base_tx.h"
13#include "base_block.h"
19unsigned int calc_num_tx_target();
20
26unsigned int get_difficulty();
27
34unsigned long calc_block_reward(unsigned long blockchain_height);
35
41Transaction *create_coinbase_tx(unsigned long total_tx_fees);
42
49unsigned int calc_tx_fees(Transaction *tx);
50
57unsigned int get_txs_from_mempool(Transaction ***tx_pts);
58
66void hash_all_tx(unsigned char *dest, Transaction **txs, unsigned int num_txs);
67
75void create_block_header(BlockHeader *header, Transaction **txs, unsigned int num_txs);
76
84BlockHeader *create_block_header_alloc(Transaction **txs, unsigned int num_txs);
85
91void create_block(Block *block);
92
99
105void change_nonce(Block *block);
106
114int try_header_hash(BlockHeader *block_header);
115
void create_block(Block *block)
Create a block from mempool to then be mined.
Definition: create_block.c:119
Transaction * create_coinbase_tx(unsigned long total_tx_fees)
Create coinbase transaction by adding the block reward and the fees.
Definition: create_block.c:27
unsigned int get_difficulty()
Get difficulty (number of zeros desired in hash for proof-of-work.
Definition: create_block.c:17
Block * create_block_alloc()
Creates a block and allocates the memory for it.
Definition: create_block.c:125
int try_header_hash(BlockHeader *block_header)
Hash header and compare against difficulty, determine if Proof-of-Work is met.
Definition: create_block.c:135
Block * mine_block()
Try mining a block.
Definition: create_block.c:150
BlockHeader * create_block_header_alloc(Transaction **txs, unsigned int num_txs)
Creats a block header and allocates memory for it.
Definition: create_block.c:113
unsigned long calc_block_reward(unsigned long blockchain_height)
Calculate the reward for mining this block.
Definition: create_block.c:21
void create_block_header(BlockHeader *header, Transaction **txs, unsigned int num_txs)
Create block header from a set of transactions.
Definition: create_block.c:106
unsigned int get_txs_from_mempool(Transaction ***tx_pts)
Collect Transactions for a new block, including coinbase tx.
Definition: create_block.c:68
void hash_all_tx(unsigned char *dest, Transaction **txs, unsigned int num_txs)
Create the hash of all the transaction hashes, used in block header.
Definition: create_block.c:97
void change_nonce(Block *block)
increments nonce of a block to try hashing/mining again
Definition: create_block.c:131
unsigned int calc_tx_fees(Transaction *tx)
Calculate the transaction fees from a single tx.
Definition: create_block.c:47
unsigned int calc_num_tx_target()
Get the current number of desired transactions for within a block.
Definition: create_block.c:13
Definition: base_block.h:5
Definition: base_block.h:12
Definition: base_tx.h:19