Today we will do some really important stuff for a blockchain.
To fit the blocks to our needs we need some last lines.
As you can see i added the public and private sections in our block class.
At the public section, i added a constructor, a function to return the hash of the actual block and a function to mine the block. Don't worry, we will fill the functions with code later on. And i also added the hash of the previous block on the public section.
In the private section we find the index, timestamp, data and the hash of the actual block. And a function to calculate the hash of the block. We declare it as const, so it will not accidental change the actual block.
With this lines, we finished our block class and can now start to talk about a chain.
So what did our chain class need? First of all a file =D Create a new file and call it Blockchain.h.
By the way, i created a folder called PigChain and in this folder a created a folder called src and in this folder i created the to file and will create all future files in.
Ok back to topic. What did our blockchain class need?
Ok lets type the following in:
Ok thats it. In our case the chain variable is a vector, because it is easy to use and it is nearly a chain and we can iterate through it. Everything else should be self explained.
So i think we got it for now. On the next tutorial we will fill the classes with code and start to fill up our chain with life.