MCPcopy Create free account
hub / github.com/divan/txqr / NewDecoderSize

Function NewDecoderSize

decode.go:29–39  ·  view source on GitHub ↗

NewDecoderSize creates and inits a new decoder for the known size.

(size, chunkLen int)

Source from the content-addressed store, hash-verified

27
28// NewDecoderSize creates and inits a new decoder for the known size.
29func NewDecoderSize(size, chunkLen int) *Decoder {
30 numChunks := numberOfChunks(size, chunkLen)
31 codec := fountain.NewLubyCodec(numChunks, rand.New(fountain.NewMersenneTwister(200)), solitonDistribution(numChunks))
32 return &Decoder{
33 codec: codec,
34 fd: codec.NewDecoder(size),
35 total: size,
36 chunkLen: chunkLen,
37 cache: make(map[string]struct{}),
38 }
39}
40
41// Decode takes a single chunk of data and decodes it.
42// Chunk expected to be validated (see Validate) before.

Callers

nothing calls this directly

Calls 2

numberOfChunksFunction · 0.85
solitonDistributionFunction · 0.85

Tested by

no test coverage detected