MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / highwayUploadBlock

Method highwayUploadBlock

client/highway.go:99–119  ·  view source on GitHub ↗
(trans *hw.Transaction, server string, offset uint64, blkmd5 []byte, blk []byte)

Source from the content-addressed store, hash-verified

97}
98
99func (c *QQClient) highwayUploadBlock(trans *hw.Transaction, server string, offset uint64, blkmd5 []byte, blk []byte) error {
100 blksz := uint64(len(blk))
101 isEnd := offset+blksz == trans.Size
102 payload, err := sendHighwayPacket(
103 trans.Build(&c.highwaySession, offset, uint32(blksz), blkmd5), blk, server, isEnd,
104 )
105 if err != nil {
106 return fmt.Errorf("send highway packet: %w", err)
107 }
108 defer payload.Close()
109 resphead, respbody, err := parseHighwayPacket(payload)
110 if err != nil {
111 return fmt.Errorf("parse highway packet: %w", err)
112 }
113 c.debug("Highway Block Result: %d | %d | %x | %v",
114 resphead.ErrorCode, resphead.MsgSegHead.RetCode.Unwrap(), resphead.BytesRspExtendInfo, respbody)
115 if resphead.ErrorCode != 0 {
116 return errors.New("highway error code: " + strconv.Itoa(int(resphead.ErrorCode)))
117 }
118 return nil
119}
120
121func parseHighwayPacket(data io.Reader) (head *highway.RespDataHighwayHead, body *binary.Reader, err error) {
122 reader := binary.ParseReader(data)

Callers 1

highwayUploadMethod · 0.95

Calls 5

debugMethod · 0.95
sendHighwayPacketFunction · 0.85
parseHighwayPacketFunction · 0.85
BuildMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected