mirror of
https://github.com/vbatts/merkle.git
synced 2024-12-02 19:15:39 +00:00
20 lines
395 B
Go
20 lines
395 B
Go
package merkle
|
|
|
|
const (
|
|
// MaxBlockSize reasonable max byte size for blocks that are checksummed for
|
|
// a Node
|
|
MaxBlockSize = 1024 * 16
|
|
)
|
|
|
|
// DetermineBlockSize returns a reasonable block size to use, based on the
|
|
// provided size
|
|
func DetermineBlockSize(blockSize int) int {
|
|
var b = blockSize
|
|
for b > MaxBlockSize {
|
|
b /= 2
|
|
}
|
|
if b == 0 || (blockSize%b != 0) {
|
|
return 0
|
|
}
|
|
return b
|
|
}
|