hivemind
hivemind copied to clipboard
calc pending payout locally, on write
This logic currently lives in steemd's condenser_api, but will need to be implemented in hive.
It's also a requirement for switching to the new find_comments
API.
https://github.com/steemit/steem/blob/develop/libraries/plugins/apis/condenser_api/condenser_api.cpp#L1985
Boils down to something like:
void condenser_api_impl::set_pending_payout( discussion& d )
{
const auto& props = _db.get_dynamic_global_properties();
const auto& hist = _db.get_feed_history();
asset pot = _db.get_reward_fund( _db.get_comment( d.author, d.permlink ) ).reward_balance;
if( !hist.current_median_history.is_null() ) pot = pot * hist.current_median_history;
total_r2 = _db.get_reward_fund( _db.get_comment( d.author, d.permlink ) ).recent_claims;
if( total_r2 > 0 )
{
uint128_t vshares;
const auto& rf = _db.get_reward_fund( _db.get_comment( d.author, d.permlink ) );
vshares = 0
if(d.net_rshares.value > 0)
vshares = chain::util::evaluate_reward_curve( d.net_rshares.value, rf.author_reward_curve, rf.content_constant );
u256 r2 = chain::util::to256( vshares );
r2 *= pot.amount.value;
r2 /= total_r2;
d.pending_payout_value = legacy_asset::from_asset( asset( static_cast<uint64_t>(r2), pot.symbol ) );
}
}
https://developers.steem.io/tutorials-recipes/estimate_upvote