In the decentralized consensus process that takes place in the p2p network like Bitcoin to validate user transactions and avoid double spending on the block chain, the nodes of the network are rewarded with digital currency blocks.
As the behavior of the honest nodes, the chain of validations is always extended more time, where the valid transactions are supposed to be, not the double-spending ones. The protection against double spending is purely consensual. It is the consensus that determines which transaction ends in the longest valid consensus chain.
Bitcoin mining
According to Altcoin Sidekick rules of Bitcoin, the node that creates a block can include a special transaction in that block: a currency creation transaction (coinbase). In addition, the node can also choose the address of the recipient of this transaction, which, of course, will be his own. To create a block, the node that proposes that block is forced to obtain a unique arbitrary number or nonce that successfully resolves a hash enigma.
Hash is a mathematical problem that looks for the hash of the block that will be created within a target space, which defines the difficulty of mining and depends on the total processing of the network. To solve this enigma, it is necessary to obtain a unique arbitrary number or nonce that, by concatenating it with the hash pointer of the previous block and the transactions that the node proposes that the block contains and applies the hash function, the objective condition is fulfilled.
As per Altcoin Sidekick – destination space is adjustable for allow the difficulty of the puzzle to change over time as new users enter the network or old users leave it, modifying the total amount of network processing. This allows the puzzle to be difficult enough for you to attack blockchain costly, but guessing solutions can still be found at an almost fixed rate (in the case of Bitcoin, around ten minutes).
The process of achieving the nonce that solves the hash enigma is what is known as mining bitcoin , within which the distributed consensus operations explained above take place. The enigmas of mining are at the core of Bitcoin.
The random selection of the authorized node to create a new block is solved by means of the mining system called Test of work. The key idea behind the Test of work is that we can approximate the selection of an arbitrary node for, instead, the selection of nodes in proportion to a resource that we hope no one can monopolize. If, for example, that resource is the calculation power, then it is a work test system. Alternatively, it could be proportional to the property of the coin, and it is called Proof of stake.
Although it is not used in Bitcoin, the Participation Test is a legitimate alternative mining model and is used in other crypto currencies.
All these systems seek to achieve a decentralized consensus and the prevention of double spending and 51% of attack.