How to implement a persistent 'rank' for a leaderboard - looking for for some big brain thoughts

Hi all,

We have a leaderboard as part of our game that we are developing. Currently the ‘rank’ is based on your position on the leaderboard which is determined by a sort function on a specific column which relates to in-game spend.

As we want to add more functionality to the table (such as searching for your web3 wallet address) naturally the ‘rank’ which is determined by your position in the table will change.

So I’m trying to brainstorm some persistent rank ideas without needing to repeat over the whole database and change a ‘rank’ field in the DB for every person.

Appreciate any forum input!

Thanks

I think you only have two options:

  1. As you mentioned, repeat over the whole database on a regular basis and change the rank field for every person
  2. You dynamically compute the rank on-the-fly based on some input values, and the output would be a non-unique, non-sequential rank number

When looking back at arcade games, I’m pretty sure they use option number 1, where they have a sorted array and move elements back-and-forth

Option 2 is for when you can tolerate two people to have the same rank

I would personally choose option 1. Which option are you leaning towards?

2 Likes

Thanks @Apple - I really could only think of option 1 as a solution, I just felt it was a little too resource intensive to do it each time there is a transaction.

However, your thought process here ‘regular basis’ changes that. I think instead of doing it every transaction, i’ll just create a scheduler to do it every 1 hour, or even broader than that say every 12 hours / 24 hours.

Thank you - I appreciate your input here - I think it’s let me to the right decision.