MCPcopy Create free account
hub / github.com/DOSNetwork/core / sendID

Method sendID

p2p/client.go:147–174  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

145}
146
147func (c *client) sendID(ctx context.Context) (errc chan error) {
148 errc = make(chan error)
149 go func() {
150 defer close(errc)
151
152 var err error
153 var bytes, pubKeyBytes []byte
154 if pubKeyBytes, err = c.localPubKey.MarshalBinary(); err != nil {
155 utils.ReportError(ctx, errc, errors.Errorf("MarshalBinary: %w", err))
156 return
157 }
158
159 pID := &ID{
160 PublicKey: pubKeyBytes,
161 Id: c.localID,
162 }
163
164 if bytes, err = encodeProto(pID, c.localID, nil, 0, false); err != nil {
165 utils.ReportError(ctx, errc, errors.Errorf("encodeProto: %w", err))
166 }
167
168 if err = writeTo(bytes, c.conn); err != nil {
169 utils.ReportError(ctx, errc, errors.Errorf("writeTo: %w", err))
170 }
171 return
172 }()
173 return
174}
175
176func (c *client) run() (err error) {
177 c.sendPipe(c.encryptPipe(c.packPipe(c.dispatch(c.decodePipe(c.decryptPipe(c.readPipe()))))))

Callers 1

handShakeMethod · 0.95

Calls 3

encodeProtoFunction · 0.85
writeToFunction · 0.85
MarshalBinaryMethod · 0.45

Tested by

no test coverage detected