-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add low hash rate warning (#809)
Description --- implements: #742 Adds warning under the mine button about low hash rate. ![Screenshot from 2024-10-10 15-45-40](https://github.com/user-attachments/assets/cd75ae97-0049-462a-a96c-cc7d3ad4f878) Motivation and Context --- Miner may enter into very slow mining mode if there is not enough free RAM. How Has This Been Tested? --- Increased hash rate above my CPU capability to trigger warning. What process can a PR reviewer use to test or verify this change? --- Same as above. Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify Co-authored-by: Brian Pearce <[email protected]>
- Loading branch information
1 parent
7d54e95
commit 515d38d
Showing
14 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/containers/SideBar/components/LowHashRateWarning/LowHashRateWarning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { IoWarningSharp } from 'react-icons/io5'; | ||
import { Stack } from '@app/components/elements/Stack'; | ||
import { Typography } from '@app/components/elements/Typography'; | ||
import { useTranslation } from 'react-i18next'; | ||
import styled from 'styled-components'; | ||
import { useMiningStore } from '@app/store/useMiningStore'; | ||
|
||
const LowHashRateIcon = styled(IoWarningSharp)(({ theme }) => ({ | ||
color: theme.palette.warning.main, | ||
})); | ||
|
||
export const LowHashRateWarning = () => { | ||
const { t } = useTranslation('settings', { useSuspense: false }); | ||
const { hash_rate, is_mining } = useMiningStore((s) => s.cpu.mining); | ||
|
||
const showHashRateWarning = is_mining && hash_rate > 0 && hash_rate < 250; | ||
|
||
return showHashRateWarning ? ( | ||
<Stack direction="row" justifyContent="space-between" alignItems="center"> | ||
<LowHashRateIcon size={20} /> | ||
<Typography variant="p">{t('low-hash-rate-warning')}</Typography> | ||
</Stack> | ||
) : ( | ||
<></> | ||
); | ||
}; |