I have a Token contract and I want to record the token price once per day. So I was thinking that to cut the trouble of going trough creating a server to save the data or using a service API I would just simply save the price of token once a day in a mapping:
mapping(uint256=> uint256) public dayTokenPrice;
Since the length of this mapping will be equal to days passed from creation of the contract it will never get that big. so even after 5 years it's length will be 365 * 5
.
And in UI I will use this mapping data to create the price history of the token.
Mt question is if this is practical and would not create any problems that I'm not familiar with. my only concern is gas which wouldn't be that much since only one new item will be added to the mapping each day. Is there anything I'm missing here? what could go wrong?