def op_transfer(cls, op, tx_idx, num, date): """Process raw transfer op; apply balance if valid post promote.""" NativeAd.check_ad_payment(op, date, num) record = cls._validated(op, tx_idx, num, date) if not record: return # add payment record sql = DB.build_insert('hive_payments', record, pk='id') DB.query(sql) # read current amount sql = "SELECT promoted FROM hive_posts WHERE id = :id" curr_amount = DB.query_one(sql, id=record['post_id']) new_amount = curr_amount + record['amount'] # update post record sql = "UPDATE hive_posts SET promoted = :val WHERE id = :id" DB.query(sql, val=new_amount, id=record['post_id']) # notify cached_post of new promoted balance, and trigger update if not DbState.is_initial_sync(): CachedPost.update_promoted_amount(record['post_id'], new_amount) author, permlink = cls._split_url(op['memo']) CachedPost.vote(author, permlink, record['post_id'])
def op_transfer(cls, op, tx_idx, num, date): record = cls._validated(op, tx_idx, num, date) if not record: return # add payment record insert = DB.build_upsert('hive_payments', 'id', record) DB.query(insert) # read current amount sql = "SELECT promoted FROM hive_posts WHERE id = :id" curr_amount = DB.query_one(sql, id=record['post_id']) new_amount = curr_amount + record['amount'] # update post record sql = "UPDATE hive_posts SET promoted = :val WHERE id = :id" DB.query(sql, val=new_amount, id=record['post_id']) # notify cached_post of new promoted balance, and trigger update CachedPost.update_promoted_amount(record['post_id'], new_amount) author, permlink = cls._split_url(op['memo']) CachedPost.vote(author, permlink, record['post_id'])