Member-only story
Implementing Blockchain using GoLang
Blockchain is comprised of blocks arranged in chronological order, to form a chain. Each block stores a set of transactions. The exact definition of a transaction is specified by the system/domain for which the blockchain has been deployed. The blockchain (also known as a ledger) is replicated across a network of nodes that update and manage the shared ledger.
Block Creation
A network of nodes participating in a blockchain network records the incoming transactions and shares them with the network. This way, each node gets a copy of the current transactions, known as the “Transaction Mempool”.
A node can participate in block creation by assembling the transactions in a block and creating a block-hash. It’s possible that more than one node arrives at the same block of transactions, or there could be a race condition while building blocks. In this scenario, the node network needs to build a consensus on the blocks that are included in the blockchain.
The consensus is arrived at by using a consensus algorithm, for example, by demonstrating “proof of work”. The Proof of Work could be a difficult cryptographic problem, like creating a hash with a certain number of leading zeros at the beginning of the hash (this is determined by the difficulty level of the blockchain network).