Does anyone have the definition of
scope ? To me, it basically looks like a way to compartmentalize data in a contract so that it only accessible within a certain space. In the above example, the data
friends will exist in the contract only for the matching
username given. When a different username is given as the scope, a new
friends will exist for that usernames scope.
But also note that in that example
friends are probably multi_index containers themselves and each can contain multiple data objects within them. So you could have multiple
friends objects in your
In the token example, each account is used as the scope for the account balance. That way you have a container called
accounts which holds multiple account objects, where each account object holds your balance for that given token symbol. This way when you query a users account using their scope you will get a list of all the tokens (every ticker symbol) that users has an account with a balance for.
I think they do it this way to keep all the token symbols that a users has in one place. Whereas if you scoped it to the contract itself, you would have to redesign the two containers
currencys_stats where each account would need to hold each new token created, like with a vector or something. I guess this makes it easier to separate accounts from each other instead of getting a giant list of every account with every token symbol in existence. And easier to know who has to pay for the storage of each new token symbol added. How did they knew to design it like this in first place? Idk