Пример #1
0
func TestQueryVersion(r io.Reader) (cachedblobstore.BlobVersion, error) {
	b := make([]byte, 1)
	if _, err := r.Read(b); err != nil {
		if err == io.EOF {
			// no data -> ver 0.
			return 0, nil
		}
		return -1, fmt.Errorf("Failed to read 1 byte: %v", err)
	}

	return cachedblobstore.BlobVersion(b[0]), nil
}
Пример #2
0
func NewQueryChunkVersion(c btncrypt.Cipher) cachedblobstore.QueryVersionFunc {
	return func(r io.Reader) (cachedblobstore.BlobVersion, error) {
		var h ChunkHeader
		if err := h.ReadFrom(r, c); err != nil {
			if err == io.EOF {
				return 0, nil
			}
			return 0, err
		}

		return cachedblobstore.BlobVersion(h.PayloadVersion), nil
	}
}