func TestQueryVersion(r io.Reader) (version.Version, 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 version.Version(b[0]), nil }
func NewQueryChunkVersion(c btncrypt.Cipher) version.QueryFunc { return func(r io.Reader) (version.Version, error) { var h ChunkHeader if err := h.ReadFrom(r, c); err != nil { if err == io.EOF { return 0, nil } return 0, err } return version.Version(h.PayloadVersion), nil } }