@@ -20,6 +20,7 @@ import (
20
20
"go.opentelemetry.io/otel/trace"
21
21
22
22
"github.com/celestiaorg/go-header"
23
+ otelattr "github.com/celestiaorg/go-header/internal/otelattr"
23
24
p2p_pb "github.com/celestiaorg/go-header/p2p/pb"
24
25
)
25
26
@@ -94,7 +95,7 @@ func NewExchange[H header.Header[H]](
94
95
return ex , nil
95
96
}
96
97
97
- func (ex * Exchange [H ]) Start (ctx context.Context ) error {
98
+ func (ex * Exchange [H ]) Start (context.Context ) error {
98
99
ex .ctx , ex .cancel = context .WithCancel (context .Background ())
99
100
log .Infow ("client: starting client" , "protocol ID" , ex .protocolID )
100
101
@@ -255,7 +256,7 @@ func (ex *Exchange[H]) GetByHeight(ctx context.Context, height uint64) (H, error
255
256
log .Debugw ("requesting header" , "height" , height )
256
257
ctx , span := tracerClient .Start (ctx , "get-by-height" ,
257
258
trace .WithAttributes (
258
- attribute . Int64 ("height" , int64 ( height ) ),
259
+ otelattr . Uint64 ("height" , height ),
259
260
))
260
261
defer span .End ()
261
262
var zero H
@@ -288,17 +289,29 @@ func (ex *Exchange[H]) GetRangeByHeight(
288
289
) ([]H , error ) {
289
290
ctx , span := tracerClient .Start (ctx , "get-range-by-height" ,
290
291
trace .WithAttributes (
291
- attribute .Int64 ("from" , int64 (from .Height ())),
292
- attribute .Int64 ("to" , int64 (to )),
293
- ))
292
+ otelattr .Uint64 ("from" , from .Height ()),
293
+ otelattr .Uint64 ("to" , to ),
294
+ ),
295
+ )
294
296
defer span .End ()
295
297
session := newSession [H ](
296
- ex .ctx , ex .host , ex .peerTracker , ex .protocolID , ex .Params .RequestTimeout , ex .metrics , withValidation (from ),
298
+ ex .ctx ,
299
+ ex .host ,
300
+ ex .peerTracker ,
301
+ ex .protocolID ,
302
+ ex .Params .RequestTimeout ,
303
+ ex .metrics ,
304
+ withValidation (from ),
297
305
)
298
306
defer session .close ()
299
307
// we request the next header height that we don't have: `fromHead`+1
300
308
amount := to - (from .Height () + 1 )
301
- result , err := session .getRangeByHeight (ctx , from .Height ()+ 1 , amount , ex .Params .MaxHeadersPerRangeRequest )
309
+ result , err := session .getRangeByHeight (
310
+ ctx ,
311
+ from .Height ()+ 1 ,
312
+ amount ,
313
+ ex .Params .MaxHeadersPerRangeRequest ,
314
+ )
302
315
if err != nil {
303
316
span .SetStatus (codes .Error , err .Error ())
304
317
return nil , err
@@ -446,7 +459,9 @@ func bestHead[H header.Header[H]](result []H) (H, error) {
446
459
return res , nil
447
460
}
448
461
}
449
- log .Debug ("could not find latest header received from at least two peers, returning header with the max height" )
462
+ log .Debug (
463
+ "could not find latest header received from at least two peers, returning header with the max height" ,
464
+ )
450
465
// otherwise return header with the max height
451
466
return result [0 ], nil
452
467
}
0 commit comments