func newLazyCallRes()

in relay_messages.go [88:137]


func newLazyCallRes(f *Frame) (lazyCallRes, error) {
	if msgType := f.Header.messageType; msgType != messageTypeCallRes {
		panic(fmt.Errorf("newLazyCallRes called for wrong messageType: %v", msgType))
	}

	rbuf := typed.NewReadBuffer(f.SizedPayload())
	rbuf.SkipBytes(1)           // flags
	rbuf.SkipBytes(1)           // code
	rbuf.SkipBytes(_spanLength) // tracing

	var as []byte
	nh := int(rbuf.ReadSingleByte())
	for i := 0; i < nh; i++ {
		keyLen := int(rbuf.ReadSingleByte())
		key := rbuf.ReadBytes(keyLen)
		valLen := int(rbuf.ReadSingleByte())
		val := rbuf.ReadBytes(valLen)

		if bytes.Equal(key, _argSchemeKeyBytes) {
			as = val
			continue
		}
	}

	csumtype := ChecksumType(rbuf.ReadSingleByte()) // csumtype
	rbuf.SkipBytes(csumtype.ChecksumSize())         // csum

	// arg1: ignored
	narg1 := int(rbuf.ReadUint16())
	rbuf.SkipBytes(narg1)

	// arg2: keep track of payload
	narg2 := int(rbuf.ReadUint16())
	arg2Payload := rbuf.ReadBytes(narg2)
	arg2IsFragmented := rbuf.BytesRemaining() == 0 && hasMoreFragments(f)

	// arg3: ignored

	// Make sure we didn't hit any issues reading the buffer
	if err := rbuf.Err(); err != nil {
		return lazyCallRes{}, fmt.Errorf("read response frame: %v", err)
	}

	return lazyCallRes{
		Frame:            f,
		as:               as,
		arg2IsFragmented: arg2IsFragmented,
		arg2Payload:      arg2Payload,
	}, nil
}