A blockchain is a growing list of records, called blocks, that are linked using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data.(Defination According to Wikipedia).
So, In simple words We can say it as linked list data structure which contains some specific sort of data and every block is dependent on the previous one. Going more simpler then chain of block which are connected in a row by means of some mathematical validation Functions.
Here We can see a small blockchain demo. The hash is the mathematical function which is said above. The block are linked with hash value. How?
Suppose A block contains some specific field data like (Considering ledger application) timestamp — describing time, amount —transaction amount, transaction fee, sender, received by and for linking purpose hash from previous block.
Now at first suppose there are some blocks already in the chain and we want to add a new block in it. Procedure is like Block is created first by filling the information in the field then the hash of block which is at rear of the list (last entered block) is added in the block. For this combined data or on these whole data hash value is calculated and added to it.
Now the Question is What is hash?
Hash is Cryptographic mathematical algorithm applied on the input which generate some fixed length output. Like one give a whole page of Wikipedia in input to hash function it generates a fixed length hash of it according to the algorithm. Suppose if we just change one character in the page and again calculate hash over it the the result will be changed like more than the half no. of characters of hash will change. Also Hash Functions are considered as one-way function as by the value of calculated Hash we can’t find original Input. Most popular Hashing algorithms are SHA-512, SHA-256, MD5.
So, Why we use Hash?
The reason is it’s characteristics of mapping variable length input to fixed length output. And it will remain same for same inputs. So the need is to give security to system by intruders. let’s see how, Suppose some party tries to change some data in the previous block, like A block which contains some ledger owner’s balance. As in the BitCoin system when party A want to transfer amount x. By means of blocks which contains all the information like at checkpoint at when, what amount of money, A have and after that how many transaction he/she has done and calculate how much balance A has now. Based on that miners check the validity of transaction. So, use of hash was like if something has been changed then the value of the hash will be different from previous and for that next link could not be found so one will know that the data has been changed.
As the whole system is not centralized, every miner or miner pool and user stores the chain of block.
As there is no central intervention then how everyone get same copy or update in data how works?
So, the work of minors in the blockchain system is to validate the transaction and to calculate hash in some specific range. For that they have to generate random nonce — number generated only once and add to data. On that, they have to find this constrained hash. There is always competition between minors to calculate hash first bcz who calculate it first will get reward as well as transaction fee. When one find those hash it will broadcast in network where others will verify it and add it to their chain. So this how, the system works.