You are viewing a single comment's thread from:

RE: HiveStats: Developer's Insight

in LeoFinance3 years ago

Hello again. I have been working on this again, and found it very useful. Thank you. I was able to take your pseudo code and basically copy-pasta with little translation necessary.

At least, I think I have it working, there is one key element I don't have an answer for..

database_api.list_votes is the best I can find to get my current votes.. but this api doesn't have an option to reverse the search and get the most recent votes by an account.

any thoughts or another way that can give me the answers I am after?

my other choice is to go entirely thru the list, until I get to recent times.. and record a link in the vicinity that I can use later to avoid redundantly recalling the entire history.

Sort:  

Hey, happy to hear that it works as you want it!

database_api.list_votes is the best I can find to get my current votes

I didn't use it much, just experimented with it. So, instead of getting account's upvotes, getting post's upvotes the way to go I believe. So, you have to call it for each post. get_content already has active_votes field, so you can use that instead. Only difference is, active_votes field is limited at 1000 votes while you can query more with list_votes method.

i've succeeded using list_votes for a user, then get_content on each of those posts that is less than 7 days old (voting time) .. then check that cashout_time > currentTime .. if so I run the calc for curation rewards.

to avoid running the whole list_votes, I am retaining the closest link .. right now hardcoded in. that saves a ton of time.

query all the posts is slow, wouldn't want to run it very often.

the estimations appears close to my 7 day average.

this whole project has been a major success, thank you for helping me get a grasp on working with the hive api!

you saved me a ton of time.

i found this that is sort of an error (I could check that cash-out is zero and not send it here)

but ended up dividing by zero in the vote_reward

so I added

if { $total_vote_weight == 0 } {
    # If we don't this, divide by zero error on no-cashout.
    set ratio 0
} else {
    set ratio [expr { $curation_reward * 1000 * $weight / $total_vote_weight }]
}

an fyi.

thank you!

namaste

Posted Using LeoFinance Beta

Happy to hear that, you are welcome!

but ended up dividing by zero in the vote_reward

I probably wrote something wrong, idk, but thanks for pointing out.