Skip to content

Commit

Permalink
hide INVALID_SHARE errors from UI and refresh faucet config
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Sep 26, 2024
1 parent 7de3fbe commit 7cf0cfd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion faucet-client/src/components/mining/MiningPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export class MiningPage extends React.PureComponent<IMiningPageProps, IMiningPag
time: this.props.pageContext.faucetApi.getFaucetTime(),
showNotification: (type: string, message: string, time?: number|boolean, timeout?: number) => {
return this.props.pageContext.showNotification(type, message, time, timeout);
}
},
refreshConfig: () => this.props.pageContext.refreshConfig(),
});

this.powMiner = new PoWMiner({
Expand Down
11 changes: 9 additions & 2 deletions faucet-client/src/pow/PoWSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface IPoWSessionOptions {
client: PoWClient;
time: FaucetTime;
showNotification: (type: string, message: string, time?: number|boolean, timeout?: number) => number;
refreshConfig: () => void;
}

export interface IPoWSessionBalanceUpdate {
Expand Down Expand Up @@ -108,8 +109,11 @@ export class PoWSession extends TypedEmitter<PoWSessionEvents> {

private _submitShare(share: IPoWMinerShare) {
this.options.client.sendRequest("foundShare", share).catch((err) => {
if(err.code === "INVALID_SHARE" && err.data && err.data.message === "Invalid share params")
if(err.code === "INVALID_SHARE" && err.message === "Invalid share params") {
this.shareQueue = this.shareQueue.filter((s) => s.params !== share.params);
this.options.refreshConfig();
return; // Ignore invalid params
}

this.options.showNotification("error", "Submission error: [" + err.code + "] " + err.message, true, 20 * 1000);
});
Expand All @@ -132,8 +136,11 @@ export class PoWSession extends TypedEmitter<PoWSessionEvents> {

private _submitVerifyResult(result: IPoWMinerVerificationResult) {
this.options.client.sendRequest("verifyResult", result).catch((err) => {
if(err.code === "INVALID_VERIFYRESULT" && err.data && err.data.message === "Invalid share params")
if(err.code === "INVALID_VERIFYRESULT" && err.message === "Invalid share params") {
this.verifyResultQueue = this.verifyResultQueue.filter((s) => s.params !== result.params);
this.options.refreshConfig();
return; // Ignore invalid params
}

this.options.showNotification("error", "Verification error: [" + err.code + "] " + err.message, true, 20 * 1000);
});
Expand Down

0 comments on commit 7cf0cfd

Please sign in to comment.