Skip to content

Commit

Permalink
fixed issue with mining rewards counter in stats
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Jul 3, 2023
1 parent b3bd199 commit 32a3681
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/modules/pow/PoWClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ export class PoWClient {
let verifyValid = PoWShareVerification.processVerificationResult(verifyRes.shareId, this.getFaucetSession().getSessionId(), verifyRes.isValid);
let verifyReward = BigInt(this.module.getModuleConfig().powShareReward) * BigInt(this.module.getModuleConfig().verifyMinerRewardPerc * 100) / 10000n;
if(verifyValid && verifyReward > 0n) {
await this.getFaucetSession().addReward(verifyReward);
let addedReward = await this.getFaucetSession().addReward(verifyReward);

let faucetStats = ServiceManager.GetService(FaucetStatsLog);
faucetStats.statVerifyReward += verifyReward;
faucetStats.statVerifyReward += addedReward;

this.sendMessage("updateBalance", {
balance: this.getFaucetSession().getDropAmount().toString(),
Expand Down
25 changes: 13 additions & 12 deletions src/modules/pow/PoWShareVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,25 @@ export class PoWShareVerification {
}
});

let shareReward: bigint;
let shareReward: Promise<bigint>;
if(this.isInvalid) {
this.session.slashSession("invalid PoW result hash");
shareReward = 0n;
shareReward = Promise.resolve(0n);
}
else {
// valid share - add rewards
shareReward = BigInt(powConfig.powShareReward);
this.session.getFaucetSession().addReward(shareReward).then((amount) => {
this.session.activeClient?.sendMessage("updateBalance", {
balance: this.session.getFaucetSession().getDropAmount().toString(),
reason: "valid share (reward: " + amount.toString() + ")"
});
});
shareReward = this.session.getFaucetSession().addReward(BigInt(powConfig.powShareReward));
}
this.resultDfd.resolve({
isValid: !this.isInvalid,
reward: shareReward

shareReward.then((amount) => {
this.session.activeClient?.sendMessage("updateBalance", {
balance: this.session.getFaucetSession().getDropAmount().toString(),
reason: "valid share (reward: " + amount.toString() + ")"
});
this.resultDfd.resolve({
isValid: !this.isInvalid,
reward: amount
});
});
}

Expand Down

0 comments on commit 32a3681

Please sign in to comment.