Use adjusted increment value for author reputation awards

This commit is contained in:
Ladd Hoffman 2023-01-08 13:34:26 -06:00
parent 675fd17734
commit 7c7d01aa91
1 changed files with 5 additions and 4 deletions

View File

@ -89,9 +89,10 @@ export class Forum extends Actor {
return [];
}
const post = this.getPost(postId);
this.actions.propagateValue.log(fromActor, post, `(increment: ${increment})`);
const adjustedIncrement = increment * (1 - params.leachingValue * post.totalCitationWeight);
const rewards = new Map();
const addReward = (id, value) => rewards.set(id, (rewards.get(id) ?? 0) + value);
const addRewards = (r) => {
@ -103,12 +104,12 @@ export class Forum extends Actor {
// Increment the value of the post
// Apply leaching value
const currentValue = this.getPostValue(postId);
const newValue = currentValue + increment * (1 - params.leachingValue * post.totalCitationWeight);
const newValue = currentValue + adjustedIncrement;
await this.setPostValue(postId, newValue);
// Award reputation to post author
console.log('reward for post author', post.authorPublicKey, increment);
addReward(post.authorPublicKey, increment);
console.log('reward for post author', post.authorPublicKey, adjustedIncrement);
addReward(post.authorPublicKey, adjustedIncrement);
// Recursively distribute reputation to citations, according to weights
for (const { postId: citedPostId, weight } of post.citations) {