ipld-eth-server/vendor/github.com/ipfs/go-unixfs/importer/helpers/helpers.go
Elizabeth Engelman 36533f7c3f Update vendor directory and make necessary code changes
Fixes for new geth version
2019-09-25 16:32:27 -05:00

31 lines
1.1 KiB
Go

package helpers
import (
"fmt"
)
// BlockSizeLimit specifies the maximum size an imported block can have.
var BlockSizeLimit = 1048576 // 1 MB
// rough estimates on expected sizes
var roughLinkBlockSize = 1 << 13 // 8KB
var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name + protobuf framing
// DefaultLinksPerBlock governs how the importer decides how many links there
// will be per block. This calculation is based on expected distributions of:
// * the expected distribution of block sizes
// * the expected distribution of link sizes
// * desired access speed
// For now, we use:
//
// var roughLinkBlockSize = 1 << 13 // 8KB
// var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name
// // + protobuf framing
// var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
// = ( 8192 / 47 )
// = (approximately) 174
var DefaultLinksPerBlock = roughLinkBlockSize / roughLinkSize
// ErrSizeLimitExceeded signals that a block is larger than BlockSizeLimit.
var ErrSizeLimitExceeded = fmt.Errorf("object size limit exceeded")