@@ -10,7 +10,22 @@ import { DEFAULT_AUTHORITY_PUBLIC_KEY, getPoolConfig } from "../../config-templa
1010
1111export const TranslatorProxyConfigForm = ( { data, updateData, onContinue } : any ) => {
1212 const [ userIdentity , setUserIdentity ] = useState ( data . userIdentity || "" ) ;
13- const [ minIndividualMinerHashrate , setMinIndividualMinerHashrate ] = useState ( data . minIndividualMinerHashrate || 10000000000000.0 ) ;
13+
14+ // Convert H/s to Th/s for display (1 Th/s = 1e12 H/s)
15+ const convertHashesToTerahashes = ( hashesPerSecond : number ) : number => {
16+ return hashesPerSecond / 1e12 ;
17+ } ;
18+
19+ // Convert Th/s to H/s for storage (1 Th/s = 1e12 H/s)
20+ const convertTerahashesToHashes = ( terahashesPerSecond : number ) : number => {
21+ return terahashesPerSecond * 1e12 ;
22+ } ;
23+
24+ // Initialize with Th/s value (convert from H/s if exists, otherwise default to 100 Th/s)
25+ const initialHashrateH = data . minIndividualMinerHashrate || 10000000000000.0 ; // Default: 100 Th/s in H/s
26+ const initialHashrateTh = convertHashesToTerahashes ( initialHashrateH ) ;
27+ const [ minIndividualMinerHashrateTh , setMinIndividualMinerHashrateTh ] = useState ( initialHashrateTh ) ;
28+
1429 // Default aggregate_channels: true for non-JD (pool templates), false for JD (constructing templates)
1530 // If constructTemplates is true (JD), default to false. Otherwise default to true (non-JD).
1631 const constructTemplates = data ?. constructTemplates ;
@@ -28,9 +43,11 @@ export const TranslatorProxyConfigForm = ({ data, updateData, onContinue }: any)
2843
2944 const handleSubmit = ( e : React . FormEvent ) => {
3045 e . preventDefault ( ) ;
46+ // Convert Th/s to H/s before storing
47+ const minIndividualMinerHashrateH = convertTerahashesToHashes ( minIndividualMinerHashrateTh ) ;
3148 updateData ( {
3249 userIdentity,
33- minIndividualMinerHashrate,
50+ minIndividualMinerHashrate : minIndividualMinerHashrateH ,
3451 aggregateChannels,
3552 clientSharesPerMinute : sharesPerMinute ,
3653 tproxyUpstreamAuthorityPubkey : upstreamAuthorityPubkey
@@ -83,18 +100,18 @@ export const TranslatorProxyConfigForm = ({ data, updateData, onContinue }: any)
83100 className = "space-y-4 pt-4"
84101 >
85102 < div className = "space-y-2" >
86- < Label htmlFor = "minIndividualMinerHashrate" > Min Individual Miner Hashrate (H /s)</ Label >
103+ < Label htmlFor = "minIndividualMinerHashrate" > Min Individual Miner Hashrate (Th /s)</ Label >
87104 < Input
88105 id = "minIndividualMinerHashrate"
89106 type = "number"
90107 step = "0.1"
91- placeholder = "10000000000000 "
92- value = { minIndividualMinerHashrate }
93- onChange = { ( e ) => setMinIndividualMinerHashrate ( parseFloat ( e . target . value ) || 0 ) }
108+ placeholder = "100 "
109+ value = { minIndividualMinerHashrateTh }
110+ onChange = { ( e ) => setMinIndividualMinerHashrateTh ( parseFloat ( e . target . value ) || 0 ) }
94111 className = "bg-black/20 border-white/10"
95112 />
96113 < p className = "text-xs text-muted-foreground" >
97- Minimum hashrate threshold for individual miners, expressed in H/s (hash per second). Example: 100Th/s = 100.000.000.000.000 H/s (enter as 10000000000000)
114+ Minimum hashrate threshold for individual miners, expressed in Th/s.
98115 </ p >
99116 </ div >
100117
0 commit comments