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

Function sendHighwayPacket

client/highway.go:140–161  ·  view source on GitHub ↗
(packet *highway.ReqDataHighwayHead, block []byte, serverURL string, end bool)

Source from the content-addressed store, hash-verified

138}
139
140func sendHighwayPacket(packet *highway.ReqDataHighwayHead, block []byte, serverURL string, end bool) (io.ReadCloser, error) {
141 marshal, err := proto.Marshal(packet)
142 if err != nil {
143 return nil, err
144 }
145 buf := hw.Frame(marshal, block)
146 data, err := io.ReadAll(&buf)
147 if err != nil {
148 return nil, err
149 }
150 return postHighwayContent(bytes.NewReader(data), serverURL, end)
151 /*
152 return postHighwayContent(
153 binary.NewBuilder(nil).
154 WriteBytes([]byte{0x28}).
155 WriteU32(uint32(len(marshal))).
156 WriteU32(uint32(len(block))).
157 WriteBytes(marshal).
158 WriteBytes(block).
159 WriteBytes([]byte{0x29}).ToReader(), serverURL, end)
160 */
161}
162
163func postHighwayContent(content io.Reader, serverURL string, end bool) (io.ReadCloser, error) {
164 // Parse server URL

Callers 1

highwayUploadBlockMethod · 0.85

Calls 3

postHighwayContentFunction · 0.85
ReadAllMethod · 0.80
MarshalMethod · 0.45

Tested by

no test coverage detected