For few years I had the impression that the Blockchain is nothing but
an array of a defined data structure, the so called "Blocks".
This
Stack Overflow that I found today has made me ask many questions.
I am not proficient in reading C++ so I would like to ask here people who can read and understand Bitcoin's
official implementation on
Github.
Alternatively I will learn more about C++ however this would take longer than actually asking here and hoping
to get an answer
My understanding of how Blockchains are implemented is the following:
You create a class Block such as:
class Block {
constructor(index, timestamp, nonce, prevBlockHash, hash, transactions) {
this.index = index;
this.timestamp = timestamp;
this.prevBlockHash = prevBlockHash;
this.hash = hash;
this.transactions = transactions;
this.nonce = nonce;
}
}
Then we have the Blockchain which apparently,
is a toy implementation to initiate a chain as an array
. Therefore this implementation is wrong:
class Blockchain {
constructor() {
this.chain = [GenesisBlock()]; [b]/// array containing all Blocks[/b]
}
}
Obviously, when creating a new Block I would expect to push it into our chain array but since there is no array, then how Bitcoin does it?
Can someone clarify it? I am extremely confused in this moment and I tried to understand it the entire last week.