Fixup, distribute rewards to voters
This commit is contained in:
parent
6cc1c25b37
commit
e777a0ee85
|
@ -84,8 +84,6 @@ export class Forum extends Actor {
|
||||||
const post = this.getPost(postId);
|
const post = this.getPost(postId);
|
||||||
post.setStatus('Validated');
|
post.setStatus('Validated');
|
||||||
const rewards = await this.propagateValue(pool, post, initialValue);
|
const rewards = await this.propagateValue(pool, post, initialValue);
|
||||||
const totalRewards = Array.from(rewards.values()).reduce((total, value) => total += value, 0);
|
|
||||||
console.log('total awards from forum:', totalRewards);
|
|
||||||
// Apply computed rewards
|
// Apply computed rewards
|
||||||
for (const [id, value] of rewards) {
|
for (const [id, value] of rewards) {
|
||||||
bench.reputations.addTokens(id, value);
|
bench.reputations.addTokens(id, value);
|
||||||
|
@ -114,7 +112,7 @@ export class Forum extends Actor {
|
||||||
await this.setPostValue(post, post.value + adjustedIncrement);
|
await this.setPostValue(post, post.value + adjustedIncrement);
|
||||||
|
|
||||||
// Award reputation to post author
|
// Award reputation to post author
|
||||||
console.log('reward for post author', post.authorPublicKey, adjustedIncrement);
|
console.log(`reward for post author ${post.authorPublicKey}`, adjustedIncrement);
|
||||||
addReward(post.authorPublicKey, adjustedIncrement);
|
addReward(post.authorPublicKey, adjustedIncrement);
|
||||||
|
|
||||||
// Recursively distribute reputation to citations, according to weights
|
// Recursively distribute reputation to citations, according to weights
|
||||||
|
|
|
@ -230,14 +230,19 @@ export class ValidationPool extends Actor {
|
||||||
const { reputationPublicKey } = this.voters.get(signingPublicKey);
|
const { reputationPublicKey } = this.voters.get(signingPublicKey);
|
||||||
const reward = (tokensForWinners * stake) / getTotalStaked(votePasses);
|
const reward = (tokensForWinners * stake) / getTotalStaked(votePasses);
|
||||||
rewards.set(reputationPublicKey, reward);
|
rewards.set(reputationPublicKey, reward);
|
||||||
console.log(`reward for winning voter ${reputationPublicKey}:`, reward);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const awardsFromVoting = Array.from(rewards.values()).reduce((total, value) => total += value, 0);
|
const authorReputationPublicKey = this.voters.get(this.authorSigningPublicKey).reputationPublicKey;
|
||||||
console.log('total awards from voting:', awardsFromVoting);
|
// Distribute awards to voters other than the author
|
||||||
|
for (const [id, value] of rewards) {
|
||||||
|
if (id !== authorReputationPublicKey) {
|
||||||
|
this.bench.reputations.addTokens(id, value);
|
||||||
|
console.log(`reward for winning voter ${id}:`, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (votePasses) {
|
if (votePasses) {
|
||||||
const authorReputationPublicKey = this.voters.get(this.authorSigningPublicKey).reputationPublicKey;
|
// Distribute awards to author via the forum
|
||||||
const tokensForAuthor = this.tokensMinted * params.stakeForAuthor + rewards.get(authorReputationPublicKey);
|
const tokensForAuthor = this.tokensMinted * params.stakeForAuthor + rewards.get(authorReputationPublicKey);
|
||||||
|
|
||||||
if (votePasses && !!this.forum) {
|
if (votePasses && !!this.forum) {
|
||||||
|
|
Loading…
Reference in New Issue