Skip to content

Commit feeb977

Browse files
authored
Merge pull request #5 from GitGab19/main
handle hashrate in Th/s instead of H/s in TranslatorProxyConfigForm
2 parents 31092ba + 8d937a9 commit feeb977

File tree

2 files changed

+102
-7
lines changed

2 files changed

+102
-7
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
# Type checking and build verification
13+
typecheck:
14+
name: TypeScript Type Check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Type check
29+
run: npx tsc --noEmit
30+
31+
# Build verification
32+
build:
33+
name: Build Package
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Setup Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: '20'
42+
cache: 'npm'
43+
44+
- name: Install dependencies
45+
run: npm ci
46+
47+
- name: Build
48+
run: npm run build
49+
50+
- name: Verify build output
51+
run: |
52+
test -d dist || (echo "dist directory not found" && exit 1)
53+
test -f dist/index.js || (echo "dist/index.js not found" && exit 1)
54+
test -f dist/index.d.ts || (echo "dist/index.d.ts not found" && exit 1)
55+
56+
# Demo build verification
57+
demo-build:
58+
name: Demo Build
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v4
62+
63+
- name: Setup Node.js
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: '20'
67+
cache: 'npm'
68+
69+
- name: Install dependencies
70+
run: npm ci
71+
72+
- name: Build demo
73+
run: npm run demo:build
74+
75+
- name: Verify demo build output
76+
run: |
77+
test -d demo/dist || (echo "demo/dist directory not found" && exit 1)
78+

src/wizard/forms/TranslatorProxyConfigForm.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,22 @@ import { DEFAULT_AUTHORITY_PUBLIC_KEY, getPoolConfig } from "../../config-templa
1010

1111
export 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

Comments
 (0)