An "under the hood question" about actual contract storage elements. If I add an element to a contract storage data time, for example, a list of zombies owned by different people in a game, what actually happens on the block chain?

Since the blockchain is immutable, I assume that the original map content is not touched, and that a new block is created on the public ledger that reflects the updated content of the zombie to owner map.

If that is correct, how does anyone querying my smart contract get (directed to/routed to/not sure how to say this) end up getting the results of the updated owner to zombies map instead of an older copy of that mapping from a block that is on the block chain? In other words, how does the node software "know" to find the latest copy of the storage element and if so, what kind of search method does it use to do that? (e.g. - if it is a linear search, wouldn't that mean if a smart contract records every transaction to the block chain that the search times would get extraordinarily long and if so, does this cost a lot of gas to execute?)

And going the other direction, is it still possible for me to query the content of previous/older images of the owner to zombie map printed earlier to the blockchain? For example, let's say I want to create an audit history of changes to the owner to zombie map over time?

If there is a really good book, PDF, guide, etc. that goes into the details of how this works and what some of the strategic optimization nuances are with the mechanics of how smart contract storage elements are updated/searched-for over time, that would be appreciated.

  • 1
    An accesible read is Ethereum's white paper – Ismael Mar 11 '18 at 16:17
  • @Ismael Thanks for the "How is contract storage arranged?" link. That is very helpful. I believe that in the case of such a difficult question to formulate, having additional question variants will help people find the link you added as a comment since many won't know to structure the question that way (like myself). My opinion. Thanks for your help. – Robert Oschler Mar 11 '18 at 16:43