Saving only last operation
Loading
-
Side notes first:
- it would make sense to combine
author_reward_operationintocomment_reward_operation- they only exist one after another and they always have the same involved comment and account; we are getting rid of one operation per comment that way - it would make sense to calculate sum of curator rewards during actual payout and put that information in
comment_reward_operationas well; we will no longer need to handlecuration_reward_operationwhen updating post information (the operation itself is still needed as it involves curator account which is different from author)
Now, the changes of this commit won't work because they break operation order and it is essential. In particular you'll get different results if you have
effective_comment_vote_operationfirst andcomment_reward_operationsecond (pending will be zero as the latter cancels effects of the former), then when they are in opposite order. You cannot group operations by their type, they have to remain grouped by key as they were.If the side notes are applied then the simplest thing to do is to iterate original operations in reverse, since last operation wins (*):
- when key is not present and you get
vop=comment_reward_operationyou create recordcomment_payout_ops[key] = { vop, None, None, author, permlink } - when key is not present and you get
vop=effective_comment_vote_operationyou create recordcomment_payout_ops[key] = { None, vop, None, author, permlink } - when key is not present and you get
vop=comment_payout_update_operationyou create recordcomment_payout_ops[key] = { None, None, True, author, permlink } - when key is present and you get
vop=comment_reward_operationyou supplement the record withcomment_payout_ops[key].first = vop(* you can do this safely as long as the range of blocks is 1000 and not close to 28k+ when you could encounter more than one such operation with the same key) - when key is present and you get
vop=effective_comment_vote_operationif bothfirstandsecondareNone(onlyTrueonthird) you supplement the record withcomment_payout_ops[key].second = vop, otherwise you ignore the operation - when key is present and you get
vop=comment_payout_update_operationyou can probably assert since that is not possible
As you can see I've also proposed putting
authorandpermlinkin the above record instead of invalfor each operation. - it would make sense to combine
Please sign in to comment