Files
core/merkle/Fragment.go
Akilan Selvacoumar ae5f1d2fd7 New features (#110)
* added upload status

* added changes for progress bar with more logs and bug fixes, Documentation yet to be added

* huge changes that need more doucmenting

* added possibility to get profile using NodeID

* added fix profile listing user profile information

* removed profile image from the explore reult struct

* saving current changes

* added filter to search based on NodeID

* Monday bug fixing

* updates to the profile

* changes for tracing the blockchain profile image not shown

* added condition to ensure TAG is not sent and removed debug prints

* updated webapi docs
2023-06-28 00:38:17 +01:00

58 lines
1.0 KiB
Go

/*
File Username: Fragment.go
Copyright: 2021 Peernet s.r.o.
Author: Peter Kleissner
*/
package merkle
// MinimumFragmentSize is the minimum size a fragment must be. Merkle trees are not used equal or below that size.
const MinimumFragmentSize = 256 * KB
const KB = 1024
const MB = 1024 * KB
const GB = 1024 * MB
const TB = 1024 * GB
const PB = 1024 * TB
// CalculateFragmentSize calculates the fragment size based on the file size.
func CalculateFragmentSize(fileSize uint64) (fragmentSize uint64) {
switch {
case fileSize <= 256*MB:
return 256 * KB
case fileSize <= 1*GB:
return 512 * KB
case fileSize <= 2*GB:
return 1 * MB
case fileSize <= 4*GB:
return 2 * MB
case fileSize <= 8*GB:
return 8 * MB
case fileSize <= 16*GB:
return 16 * MB
case fileSize <= 32*GB:
return 32 * MB
case fileSize <= 64*GB:
return 64 * MB
case fileSize <= 1*TB:
return 64 * MB
case fileSize <= 2*TB:
return 128 * MB
case fileSize <= 1*PB:
return 512 * MB
default: // 1 PB+
return 1 * GB
}
}