What is scotbot
Scotbot is the backend for all scot tribes which streams continuously steem blocks and parses all scot related comments/posts, votes and custom_json operations. scotbot keeps track of token vote power and the amount of pending tokens and when a post is paid out, it calculates the amount of tokens and adds them to the author and all voter as pending rewards which can be claimed.
Speeding up scotbot
Finally, scotbot keeps track of the weighted rshares sum for all pending posts without recalculating them everytime from scratch. This is a huge step which reduces the delay of scotbot to around 15 to 20 seconds.
When a post is upvoted, rshares depending on the vote weight, power and staked tokens are added to the post and increase the amount of pending tokens. When the scot has a nonlinear reward curve, the rshares sum of the post is weighted by a non linear curve.
pending_rshares is then the sum of all weighted rshares from all pending posts.
The reward of a post is calculated by:
weight_rshares / pending_rshares * reward_pool
Whenever a new vote arrives, the old and new weighted rshares is calculated, and the pending_rshares sum is corrected by:
pending_rshares = pending_rshares + weight_rshares - old_weight_rshares
When a post is paid out, its weighted rshares is subtracted from
With these changes, it is not necessary anymore to go through all pending posts and sum up their rshares which is time consuming.
Converting all tags to lower cases
Before this change, scotbot could not regonize a post with a capital letter in the tag, e.g. Palnet instead of palnet. This is now fixed and tags are always converted to lower cases before checking them.
Checking if claimed token were correctly paid out
Before this change, scotbot was checking if a custom_json for issuing claimed tokens was broadcasted to a steem node without error.
After analyzing the logs, I found that it is not guaranteed that a broadcasted operation is written to the steem blockchain. In rare cases, it can be revoked and then the broadcasted custom_json cannot be found in the steem blockchain. Now, all broadcasted custom_json attempts and when found the matching custom json transaction id is stored in the database. Whenever a custom_json expires without finding a valid trx_id, the pending token amount is added again to the account and the user can claim a second time.
scotbot is faster than ever, allows tags with capital letters and double checks if claimed token are send out.