Content
@
0 reply
0 recast
0 reaction
Noah Bragg 🔥
@nbragg
Solidity devs: How possible is it to store a large array to hold a leaderboard onchain? It would need to be updated as it changes and shifted around. My gut reaction as that this would be too expensive to make happen. Is on a layer2 at least. Or are there any better solutions?
7 replies
0 recast
5 reactions
ndx 🐉
@ndx.eth
Maybe possible if you use a binary or red-black tree? The worst case rebalancing scenario + block gas limit might limit the number of participants, but the best/average case would probably be fairly efficient.
1 reply
0 recast
1 reaction
Noah Bragg 🔥
@nbragg
thanks, I'm thinking for my situation a linked list may be best because I only need to traverse a few users on the leaderboard close to a player.
1 reply
0 recast
0 reaction
iain
@iain
Yep I think a linked list is a good call here. You can tell which node to insert after on the client and just confirm the prev next scores are as expected when amending then do a pointer lookup of user to node.
0 reply
0 recast
0 reaction