1
0
Fork 0
mirror of https://github.com/vbatts/merkle.git synced 2024-12-02 19:15:39 +00:00
merkle/block.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
}