This contribution applies to all commits in the repository.
Introduction to the #ivoted project
#ivoted is an initiative created by @sebbbl and @algo.coder.
It aims to act as a democracy incentive. The goal is to encourage people to vote for witnesses, rewarding them with lifetime weekly upvotes from the account @ivoted.
The code submitted here is the bot running 24/7 on the @ivoted account.
Its goals are :
- to allow people to enter the program, by detecting @ivoted mentions or #ivoted tags,
- and then upvote them weekly, according to the number of witness votes they casted.
This is the initial commit of the bot.
The bot is based on a perpetual loop on the main thread that launches other threads with specific tasks :
- Every second, it will check for new blocks to treat them by launching a new thread executing the get_block() function (looking for the use of the tags or mentions of the account).
- Every hour, it updates the participants' informations with a new thread executing update_users().
- Every minute, it will print a sum up of what happened in the last minute, for debugging purposes.
This function gets the last irreversible block available, and then launches a thread for each block that hasn't yet been scanned. The 0.1 second time sleep is there to make sure there won't be two threads launched with the same block, thanks to the redundant check implemented in the treat_block() function.
This function first adds the block it will treat in a list to avoid running several threads scanning the same block. It also checks that all blocks have been scanned. If there's a gap between the last block treated and the block now treated (and the blocks in the gap aren't currently being scanned), it launches new threads to close the gap.
If any of these conditions is fullfilled, it launches the treat_post() function, that will insert the author of the post / comment in the database, validating its subscription to the program.
Every hour, informations (amount of Steem Power and witness votes) about the participants are updated in the database.
Once updated, the get_accounts() function is launched to extract all participants from the database, putting all informations needed for the upvoting side of the bot in a list.
This is a perpertual loop, whose task is to upvote weekly all participants in the program.
1 > It checks if the current Voting Power of the account is superior to the limit fixed by the Policy of the account (here 95%, in the vp_limit variable)
2 > If the VP is above that limit, then:
3 > It loops through all the accounts to find the first that have not been voted in the last 7 days. It retrieves the history of this account to find the last post. If there is no post in the last 7 days, it will try to find the last comment posted. If there is none, it goes on to the next account.
4 > If a post or comment has been found, it upvotes it with a power percentage determined by the calculation described in the Policy.
5 > Then it record the vote casted in the database, and updates the information in the ACCOUNTS table, so the user is not upvoted in the next seven days.
This function is used to get the real Voting Power of the account.
This function is used to get some values of the Steem Blockchain used for calculation (especially Steem per MVests).
How to contribute ?
You can contribute by creating pull requests on the repository mainly:
- By correcting errors you might see in the code,
- By optimizing it,
- By any way you would see fit.
Governance and policy
Introduction of @ivoted, a witness voting incentive bot
Official launch of the #ivoted initiative
Complete list of witnesses
Vote for witnesses and get engaged in the #ivoted initiative - Howto
The ivoted website