Appending blocks to blockchain

Now, we understand how transactions are added to a block. In this section, we'll look at how a block is added to the blockchain. We already know that the block header contains mixHash and nonce, which prove the sufficiency of the computations performed on the block. This sufficiency of computation is defined as the total difficulty a miner had to go through to create a new block. The algorithm for total difficulty or the block difficulty is called the PoW algorithm (also known as Ethash in Ethereum). A block is only valid if it contains PoW of a given difficulty (maybe soon to be replaced with PoS).

A seed is calculated for each block by scanning the header of the block until that point in time. From the seed, a pseudo-random cache is computed and, from the cache, a dataset is generated. Full clients and miners need to store this dataset. Miners will randomly pick a few slices of the dataset and will hash them together into mixHash. Each miner will continue to repeat this set of generating mixHashes, until the mixHash matches the nonce. When the mixHash matches the nonce, the nonce is considered valid and hence the block is considered valid and can be added to the blockchain. Transactions that are part of this block are also considered to be confirmed.

Remember, there are many miners on the network, and they get to hear about the transaction at different times. Hence, each miner is mining different transactions (this could also be based on the transaction fee associated with each transaction), and so is generating its own block. Since each miner is building its own block with its own set of transactions in it, how does the block that gets mined and validated come to a common agreement? They reach a common agreement based on the consensus.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset