Mining is the so-called process where transactions are being verified and added to the blockchain
network. Besides validating transactions, miners are also responsible for adding new coins
to the existing supply.
Assemble the transactions. A miner is a so-called node in the network. When a transaction is created, all nodes receive it and verify the validity. After that, nodes aggregate all open transactions into a block.
There are different types of nodes; there are mining nodes, full nodes, light nodes and supernodes. All of them hold the blockchain ledger, except for the light node, which only contains a part of it. Only the mining node is able to create new blocks.
Creating a block. After that, all transactions need to be hashed individually. As soon as all the transactions are hashed, the hashes will get formed to a so-called Merkle Tree (hash-tree). The output is then organized into pairs and hashed again, this process repeats itself until “the top of the tree” (Merkle Root) is reached.
The so-called Merkle Root is basically a single hash that represents all the previous generated hashes. When you hash the hash of the last block with the current Merkle Root, you get the new block hash.
Each time a new node/miner joins the network, the competition and hashing difficulty increases. This way, the system prevents the average block time from decreasing. On the other side, when miners leave the network, the hashing difficulty will go down.
The mining node adds a transaction wherein the node transfer itself the mining reward (block-reward). The block reward is given to the miner who discovers the legit hash first.
The chance of finding the hash first is similar to the share of the total mining power. Miners with small mining power stand a little chance of discovering the hash first. Mining pools were created to solve the issue. A network of miners who share the rewards equally among the pool according to their effort/work.