Skip to content

Commit

Permalink
Add payment_end_time to worker request
Browse files Browse the repository at this point in the history
  • Loading branch information
isteric-senior committed Jul 23, 2020
1 parent b1be8f6 commit 21b9581
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace golos { namespace plugins { namespace worker_api {
share_type upvote_total;
asset paid_out;
asset paid_out_vests;
time_point_sec payment_end_time;
};

struct by_net_rshares;
Expand Down Expand Up @@ -94,7 +95,8 @@ namespace golos { namespace plugins { namespace worker_api {
upvote_rshares(o.upvote_rshares),
upvote_total(o.upvote_total),
paid_out(o.paid_out),
paid_out_vests(o.paid_out_vests) {
paid_out_vests(o.paid_out_vests),
payment_end_time(o.payment_end_time) {
}

worker_request_api_object() {
Expand Down Expand Up @@ -135,6 +137,7 @@ namespace golos { namespace plugins { namespace worker_api {
asset paid_out;
asset paid_out_vests;
asset remaining_payment;
time_point_sec payment_end_time;
};

} } } // golos::plugins::worker_api
Expand All @@ -150,5 +153,5 @@ FC_REFLECT((golos::plugins::worker_api::worker_request_api_object),
(creation_fee)
(upvotes)(downvotes)
(stake_rshares)(stake_total)(upvote_rshares)(upvote_total)
(paid_out)(paid_out_vests)(remaining_payment)
(paid_out)(paid_out_vests)(remaining_payment)(payment_end_time)
)
15 changes: 15 additions & 0 deletions plugins/worker_api/worker_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ struct post_operation_visitor {
o.paid_out_vests += op.reward_in_vests_if_vest;
});
}

result_type operator()(const worker_state_operation& op) const {
if (op.state != worker_request_state::payment_complete) {
return;
}

const auto& post = _db.get_comment(op.author, op.permlink);

const auto& wrmo_idx = _db.get_index<worker_request_metadata_index, by_post>();
auto wrmo_itr = wrmo_idx.find(post.id);

_db.modify(*wrmo_itr, [&](auto& o) {
o.payment_end_time = _db.head_block_time();
});
}
};

class worker_api_plugin::worker_api_plugin_impl final {
Expand Down

0 comments on commit 21b9581

Please sign in to comment.