0

I was looking into how to store large amount of addreses for example to adding atributes to different token holders.

As far as i know, most people use mapping, i was researching how that works but the only information i could find was "You can think of mappings as hash tables" so i assume the complexity will be O(1) avg and worst case O(n)

So taking into consideration that will be necesary to check that attibutes every time an address sold some tokens and the order of the elements doesnt matter, the right way will be using mapping?

Also, some recomendations to read about how storing large amount of addresses could affect the gas fee and that?

Thank you so much i started to learn solidity few months ago and im trying to understand all better and focus on efficience.

1
  • A mapping access is O(1), the keys aren't stored in a mapping so you don't have to worry about addresses if you use them as keys.
    – Ismael
    Jul 10 at 4:46
0

Mappings are like hash tables

that means they are direct access structure; when accessing a value knowing the key it won't go through all the keys looking for the one you asked for, so the complexity is always O(1).

mappings do hash the keys when writing and reading, so they are never stored in plain value

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.