Do data types like arrays or maps get stored in the patricia tree

  • (#1)where each element (in the map) has it's own path, and when you add a new element you reference the whole sub tree and add a new path branch, or does it

  • (#2)just get saved as a single atomic value?

If the 1st is true: Cool.

If the 2nd is true: Is there a special data type that gets implemented that way?


The first is true and it's how State-Trie Pruning is done.

| improve this answer | |

The other answer is probably true, but I think it misses an important point. When you mention storing "lots of data", I think you will find that no matter how inefficient or efficient the data is stored on-chain, you won't be storing "lots" of data in a smart contract. It's astronomically expensive in gas cost. In almost every case where people need to store "lots of data" they store the actual data in something like IPFS or Swarm and store only the hash of the data on-chain. Just thought I'd make that point.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.