I refer to this - http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html
pragma solidity ^0.4.0;
contract SimpleStorage {
uint storedData;
function set(uint x) public {
storedData = x;
}
function get() public constant returns (uint) {
return storedData;
} }
It states:
Of course, anyone could just call set again with a different value and overwrite your number, but the number will still be stored in the history of the blockchain
I understood the state variables are stored in contract storage which is persistent. Are their previous values stored in the blockchain itself?
My question is really what happens if someone is storing db keys, and they have a lot of them in an array - thousands or millions.
How exactly would the array be stored when one element is changed? Does the historical storage hold only the changed array element and an index or is the whole array stored?
If I have say -
Student {
uint age;
uint studentId;
uint studentScore;
uint studentCourseFee;
}
Student[] public students;
Then I have 40,000 students so Student[] has 40K elements, and then I change one entry. What happens to the whole array? If I change entry 22,045 in the array (eg delete it), how does the historical storage record that and how does the new array get stored, now it is one entry shorter?
I can foresee scaling problems with am approach under any design here.