Fix: Correct hashrate unit display to H/s for RandomX#3264
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for formatting hashrates for the "RandomX" algorithm, which is used in CPU mining. It updates the formatHashrate utility to set the base unit to 'H' instead of 'G' when the algorithm is "RandomX", adds corresponding unit tests, and passes the "RandomX" algorithm prop to the CPU tile component. The reviewer identified a TypeScript compilation error where the algo prop passed to the tile component does not match the expected GpuMiningAlgorithm type, and suggested a type cast or a type definition update to resolve it.
| progressDiff={rewardsRef.current?.rewardValue} | ||
| unpaidFMT={rewardsRef.current?.unpaidFMT || '-'} | ||
| minerModuleState={cpuMiningModuleState} | ||
| algo="RandomX" |
There was a problem hiding this comment.
Passing the string "RandomX" to the algo prop will cause a TypeScript compilation error because MinerTileProps in Miner.tsx defines algo as GpuMiningAlgorithm (which only contains 'C29'). To fix this, MinerTileProps should be updated to accept string | GpuMiningAlgorithm. As a temporary workaround to make this file compile, you can cast it to any.
| algo="RandomX" | |
| algo={"RandomX" as any} |
Fixes #3210 by properly detecting the RandomX algorithm in CPU.tsx and formatting the unit as H/s instead of G/s. This resolves the regression where macOS (and CPU mining in general) was incorrectly showing G/s.