3

I can get some unsorted voters by using

await eos.getTableRows({
    json: true,
    code: 'eosio',
    scope: 'eosio',
    table: 'voters',
    // tableKey,
    // lowerBound,
    // upperBound,
    // limit,
    keyType: 'i64',
    indexPositio: '1'
  })

However, I wonder how to query for all the voters that are sorted based on how many votes were casted. Or even better, how to check the vote distribution of a specific block producer, similiar to what EOS Titan team is achieved here https://voters.eostitan.com/voters/50/0/21

1 Answer 1

0

From the code in eosio.system.hpp, there is no index except PK on voters. This means your tasks are not viable with eosjs it self.

I would suggest:

  1. Ask eostitan if you could use their API:

    https://explorer.eostitan.com/api/voters/${PAGE}

    e.g. https://explorer.eostitan.com/api/voters/1

  2. Find other APIs on the web.

  3. Setup your own full node with mongo_plugin. This would be a far complex process.

    What you will need to do is:

    1. Setup a mongo server.
    2. Setup a nodeos server.
    3. Configure the nodeos server to use mongo_plugin.
    4. You may want to add filter to save only all vote related action_traces into mongo. This would save you a lot of space on mongo server. If you would like keep all action_traces, in our experience, the mongo server should have at least 2TB storage.
    5. Start nodeos server and wait for sync.
    6. With all the action_traces in your mongo server, you will need to add indices that makes your aggregation queries easier.
    7. Do the aggregation queries on your mongo server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.