Skip to content

Commit fc7209e

Browse files
authored
Merge pull request #738 from ethersphere/fix-wording-4-17-25
remove burn wording
2 parents 30d62d3 + 63ab67a commit fc7209e

File tree

3 files changed

+107
-23
lines changed

3 files changed

+107
-23
lines changed

docs/develop/access-the-swarm/syncing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The `uid` value is your tag:
3232
```
3333

3434
:::info
35-
In order to upload your data to swarm, you must agree to burn some of your xBZZ to signify that the content is important. Before you progress to the next step, you must buy stamps! See this guide on how to [purchase an appropriate batch of stamps](/docs/develop/access-the-swarm/buy-a-stamp-batch).
35+
Before you progress to the next step, you must buy stamps so you can pay for uploads! See this guide on how to [purchase an appropriate batch of stamps](/docs/develop/access-the-swarm/buy-a-stamp-batch).
3636
:::
3737

3838
Pass the tag along with the upload:

docs/develop/access-the-swarm/upload-and-download.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ To upload data to the swarm, you must perform the following steps:
3939

4040
## Purchasing Your Batch of Stamps
4141

42-
In order to upload your data to swarm, you must agree to burn (spend)
43-
some of your xBZZ to signify to storer and fowarder nodes that this
44-
content is valued. Before you proceed to the next step, you must buy
45-
stamps! See this guide on how to [purchase an appropriate batch of stamps](/docs/develop/access-the-swarm/buy-a-stamp-batch).
42+
In order to upload your data to swarm, you must [purchase an appropriate batch of stamps](/docs/develop/access-the-swarm/buy-a-stamp-batch) to pay for however much data you need to upload.
4643

4744
## Using Stamps to Upload a File
4845

@@ -304,7 +301,7 @@ cd ..
304301
Next, simply POST the `tar` file as binary data to Bee's `dir` endpoint, taking care to include the header `Content Type: application/x-tar`.
305302

306303
:::info
307-
In order to upload your data to swarm, you must agree to burn some of your xBZZ to signify to storer and fowarder nodes that the content is important. Before you progress to the next step, you must buy stamps! See this guide on how to [purchase an appropriate batch of stamps](/docs/develop/access-the-swarm/buy-a-stamp-batch).
304+
Before you progress to the next step, you must buy stamps so you can pay for uploads! See this guide on how to [purchase an appropriate batch of stamps](/docs/develop/access-the-swarm/buy-a-stamp-batch).
308305
:::
309306

310307
```bash

src/components/RedundancyCalc.js

Lines changed: 104 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ export default function UploadCostCalc() {
1313
const maxParities = [9, 21, 31, 90];
1414
const maxChunksEncrypted = [59, 53, 48, 18];
1515
const errorTolerances = {
16+
None: "0%",
1617
Medium: "1%",
1718
Strong: "5%",
1819
Insane: "10%",
1920
Paranoid: "50%"
2021
};
2122

22-
2323
const formatNumberCustom = (num) => {
24+
// Modify to display integers without .00 for chunks
25+
if (unit === "chunks") {
26+
return Math.round(num).toString();
27+
}
2428
const isScientific = Math.abs(num) > 0 && Math.abs(num) < 0.0001;
25-
let formattedNum = isScientific ? num.toExponential(2) : num.toFixed(2);
26-
return formattedNum;
29+
return isScientific ? num.toExponential(2) : num.toFixed(2);
2730
};
2831

2932
const handleDataSizeChange = (e) => {
@@ -42,7 +45,6 @@ export default function UploadCostCalc() {
4245
setUnit(e.target.value);
4346
};
4447

45-
4648
const calculateCost = () => {
4749
setErrorMessage("");
4850
setResult([]);
@@ -52,6 +54,12 @@ export default function UploadCostCalc() {
5254
return;
5355
}
5456

57+
// If redundancy is None, skip erasure coding calculations
58+
if (redundancy === "None") {
59+
calculateNonRedundancyCost();
60+
return;
61+
}
62+
5563
let parityDataInGb = 0;
5664
let totalChunks, sizeInKb, sizeInGb;
5765

@@ -93,17 +101,15 @@ export default function UploadCostCalc() {
93101
: Math.ceil(totalChunks / 127); // 0.8% overhead for unencrypted files
94102

95103
// Add PAC overhead to total chunks
96-
const totalChunksWithPac = totalChunks + pacOverheadChunks;
97-
98-
const redundancyLevels = { Medium: 0, Strong: 1, Insane: 2, Paranoid: 3 };
104+
const redundancyLevels = { None: -1, Medium: 0, Strong: 1, Insane: 2, Paranoid: 3 };
99105
const redundancyLevel = redundancyLevels[redundancy];
100-
106+
101107
const quotient = isEncrypted
102-
? Math.floor(totalChunksWithPac / maxChunksEncrypted[redundancyLevel])
103-
: Math.floor(totalChunksWithPac / maxChunks[redundancyLevel]);
108+
? Math.floor(totalChunks / maxChunksEncrypted[redundancyLevel])
109+
: Math.floor(totalChunks / maxChunks[redundancyLevel]);
104110
const remainder = isEncrypted
105-
? totalChunksWithPac % maxChunksEncrypted[redundancyLevel]
106-
: totalChunksWithPac % maxChunks[redundancyLevel];
111+
? totalChunks % maxChunksEncrypted[redundancyLevel]
112+
: totalChunks % maxChunks[redundancyLevel];
107113

108114
let remainderParities = 0;
109115
if (remainder > 0) {
@@ -113,6 +119,7 @@ export default function UploadCostCalc() {
113119
}
114120

115121
const totalParities = quotient * maxParities[redundancyLevel] + remainderParities;
122+
const totalChunksWithPac = totalChunks + pacOverheadChunks;
116123
const totalDataWithParity = totalChunksWithPac + totalParities;
117124
const percentDifference = ((totalDataWithParity - totalChunks) / totalChunks) * 100;
118125

@@ -176,7 +183,89 @@ export default function UploadCostCalc() {
176183

177184
setResult(resultsArray);
178185
};
186+
187+
const calculateNonRedundancyCost = () => {
188+
let totalChunks, sizeInKb, sizeInGb;
179189

190+
if (!dataSize || isNaN(parseFloat(dataSize))) {
191+
setErrorMessage("Please enter a valid data size.");
192+
return;
193+
}
194+
195+
if (unit === "kb") {
196+
const kbValue = parseFloat(dataSize);
197+
if (isNaN(kbValue) || kbValue <= 0) {
198+
setErrorMessage("Please input a valid KB value above 0.");
199+
return;
200+
}
201+
sizeInKb = kbValue;
202+
totalChunks = Math.ceil((kbValue * 1024) / (2 ** 12));
203+
} else if (unit === "gb") {
204+
const gbValue = parseFloat(dataSize);
205+
if (isNaN(gbValue) || gbValue <= 0) {
206+
setErrorMessage("Please input a valid GB value above 0.");
207+
return;
208+
}
209+
sizeInGb = gbValue;
210+
sizeInKb = gbValue * 1024 * 1024; // Convert GB to KB
211+
totalChunks = Math.ceil((sizeInKb * 1024) / (2 ** 12));
212+
} else {
213+
const chunksValue = parseFloat(dataSize);
214+
if (isNaN(chunksValue) || chunksValue <= 1 || chunksValue % 1 > 0) {
215+
setErrorMessage("Please input an integer greater than 1 for chunk values");
216+
return;
217+
}
218+
totalChunks = Math.ceil(chunksValue);
219+
sizeInKb = (totalChunks * (2 ** 12)) / 1024;
220+
}
221+
222+
// Calculate PAC overhead
223+
const pacOverheadChunks = isEncrypted
224+
? Math.ceil(totalChunks / 63) // 1.6% overhead for encrypted files
225+
: Math.ceil(totalChunks / 127); // 0.8% overhead for unencrypted files
226+
227+
const totalChunksWithPac = totalChunks + pacOverheadChunks;
228+
const percentDifference = ((totalChunksWithPac - totalChunks) / totalChunks) * 100;
229+
230+
// Calculate PAC overhead size in KB and GB
231+
const pacOverheadInKb = (pacOverheadChunks * (2 ** 12)) / 1024;
232+
const sizeInGbCalculated = unit === "gb" ? sizeInKb / (1024 * 1024) : null;
233+
234+
const resultsArray = [
235+
{
236+
name: "Source data size",
237+
value: unit === "gb" ? `${formatNumberCustom(sizeInGbCalculated)} GB` : `${formatNumberCustom(sizeInKb)} KB`,
238+
},
239+
{
240+
name: "PAC overhead",
241+
value: unit === "gb"
242+
? `${formatNumberCustom(pacOverheadInKb / (1024 * 1024))} GB (${formatNumberCustom(pacOverheadChunks)} chunks)`
243+
: `${formatNumberCustom(pacOverheadInKb)} KB (${formatNumberCustom(pacOverheadChunks)} chunks)`,
244+
},
245+
{
246+
name: "Source data in chunks",
247+
value: formatNumberCustom(totalChunks)
248+
},
249+
{
250+
name: "Source with PAC overhead",
251+
value: formatNumberCustom(totalChunksWithPac)
252+
},
253+
{
254+
name: "Percent cost increase",
255+
value: `${percentDifference.toFixed(2)}%`
256+
},
257+
{
258+
name: "Selected redundancy level",
259+
value: `${redundancy}`
260+
},
261+
{
262+
name: "Error tolerance",
263+
value: errorTolerances[redundancy]
264+
},
265+
];
266+
267+
setResult(resultsArray);
268+
};
180269

181270
const styles = {
182271
container: { padding: '20px', fontFamily: 'Arial', maxWidth: '650px', margin: '0 auto' },
@@ -225,6 +314,7 @@ export default function UploadCostCalc() {
225314
<div style={styles.title}>Redundancy Level:</div>
226315
<select value={redundancy} onChange={handleRedundancyChange} style={styles.select}>
227316
<option value="" disabled>Select Redundancy Level</option>
317+
<option value="None">None</option>
228318
<option value="Medium">Medium</option>
229319
<option value="Strong">Strong</option>
230320
<option value="Insane">Insane</option>
@@ -245,13 +335,10 @@ export default function UploadCostCalc() {
245335
<tbody>
246336
{result.map((item, index) => (
247337
<tr key={index}>
248-
<td style={{...styles.tdName, ...styles.bold}}>{item.name}</td> {/* Apply bold style here */}
338+
<td style={{...styles.tdName, ...styles.bold}}>{item.name}</td>
249339
<td style={styles.tdValue}>{item.value}</td>
250340
</tr>
251341
))}
252342
</tbody>
253343
</table>
254-
</div>
255-
</div>
256-
);
257-
}
344+
</div>

0 commit comments

Comments
 (0)