2020-04-07 00:29:52 +00:00
|
|
|
package nullreader
|
|
|
|
|
2022-04-12 15:45:34 +00:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
)
|
|
|
|
|
|
|
|
type NullReader struct {
|
|
|
|
*io.LimitedReader
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewNullReader(size abi.UnpaddedPieceSize) io.Reader {
|
|
|
|
return &NullReader{(io.LimitReader(&Reader{}, int64(size))).(*io.LimitedReader)}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m NullReader) NullBytes() int64 {
|
|
|
|
return m.N
|
|
|
|
}
|
|
|
|
|
2020-04-07 00:29:52 +00:00
|
|
|
// TODO: extract this to someplace where it can be shared with lotus
|
|
|
|
type Reader struct{}
|
|
|
|
|
|
|
|
func (Reader) Read(out []byte) (int, error) {
|
|
|
|
for i := range out {
|
|
|
|
out[i] = 0
|
|
|
|
}
|
|
|
|
return len(out), nil
|
|
|
|
}
|