Commit ffa17637 authored by Mariusz Trela's avatar Mariusz Trela
Browse files

Saving only last operation

parent 54ca62fe
Loading
Loading
Loading
Loading
  • Maintainer

    Side notes first:

    • it would make sense to combine author_reward_operation into comment_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_operation as well; we will no longer need to handle curation_reward_operation when 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_operation first and comment_reward_operation second (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_operation you create record comment_payout_ops[key] = { vop, None, None, author, permlink }
    • when key is not present and you get vop=effective_comment_vote_operation you create record comment_payout_ops[key] = { None, vop, None, author, permlink }
    • when key is not present and you get vop=comment_payout_update_operation you create record comment_payout_ops[key] = { None, None, True, author, permlink }
    • when key is present and you get vop=comment_reward_operation you supplement the record with comment_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_operation if both first and second are None (only True on third) you supplement the record with comment_payout_ops[key].second = vop, otherwise you ignore the operation
    • when key is present and you get vop=comment_payout_update_operation you can probably assert since that is not possible

    As you can see I've also proposed putting author and permlink in the above record instead of in val for each operation.

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment