I learned blockchain concept by using some tutorials based on cryptocurrency.
However, to make me understand this fully, I am thinking of this example: A blockchain to track the ingredients for restaurants so their customers know that the food they eat are indeed from the claimed source.
In this example usage, do I still need the concept of transaction? Can't I use a minimal block like this
public class Block{
public int number;
public string hash;
public string previoushash;
public int timestamp;
public string data;
}
I am not sure how to solve a conflict? Say a restaurant and a hacker both send a block relating to an ingredient, how the algorithm knows which one is valid? The tutorial says longer chain will win, but how it works in reality?
Say in total there are 10 nodes. 2 nodes send a conflicting block (say block 10) and as a third node on the network, how can I know which block is valid if no further block has been added?