Skip to content

Commit 0206434

Browse files
committed
use url.JoinPath instead of path
1 parent 272a986 commit 0206434

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

rollup/da_syncer/blob_client/beacon_node_client.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"fmt"
88
"io"
99
"net/http"
10-
"path"
10+
"net/url"
1111
"strconv"
1212

1313
"github.com/scroll-tech/go-ethereum/common"
@@ -30,7 +30,10 @@ var (
3030

3131
func NewBeaconNodeClient(apiEndpoint string, l1Client *rollup_sync_service.L1Client) (*BeaconNodeClient, error) {
3232
// get genesis time
33-
genesisPath := path.Join(apiEndpoint, beaconNodeGenesisEndpoint)
33+
genesisPath, err := url.JoinPath(apiEndpoint, beaconNodeGenesisEndpoint)
34+
if err != nil {
35+
return nil, fmt.Errorf("failed to join path, err: %w", err)
36+
}
3437
resp, err := http.Get(genesisPath)
3538
if err != nil {
3639
return nil, fmt.Errorf("cannot do request, err: %w", err)
@@ -54,7 +57,10 @@ func NewBeaconNodeClient(apiEndpoint string, l1Client *rollup_sync_service.L1Cli
5457
}
5558

5659
// get seconds per slot from spec
57-
specPath := path.Join(apiEndpoint, beaconNodeSpecEndpoint)
60+
specPath, err := url.JoinPath(apiEndpoint, beaconNodeSpecEndpoint)
61+
if err != nil {
62+
return nil, fmt.Errorf("failed to join path, err: %w", err)
63+
}
5864
resp, err = http.Get(specPath)
5965
if err != nil {
6066
return nil, fmt.Errorf("cannot do request, err: %w", err)
@@ -97,7 +103,10 @@ func (c *BeaconNodeClient) GetBlobByVersionedHashAndBlockNumber(ctx context.Cont
97103
slot := (header.Time - c.genesisTime) / c.secondsPerSlot
98104

99105
// get blob sidecar for slot
100-
blobSidecarPath := path.Join(c.apiEndpoint, beaconNodeBlobEndpoint, fmt.Sprintf("%d", slot))
106+
blobSidecarPath, err := url.JoinPath(c.apiEndpoint, beaconNodeBlobEndpoint, fmt.Sprintf("%d", slot))
107+
if err != nil {
108+
return nil, fmt.Errorf("failed to join path, err: %w", err)
109+
}
101110
resp, err := http.Get(blobSidecarPath)
102111
if err != nil {
103112
return nil, fmt.Errorf("cannot do request, err: %w", err)

rollup/da_syncer/syncing_pipeline.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ func NewSyncingPipeline(ctx context.Context, blockchain *core.BlockChain, genesi
6060
beaconNodeClient, err := blob_client.NewBeaconNodeClient(config.BeaconNodeAPIEndpoint, l1Client)
6161
if err != nil {
6262
log.Warn("failed to create BeaconNodeClient", "err", err)
63+
} else {
64+
blobClientList.AddBlobClient(beaconNodeClient)
6365
}
64-
blobClientList.AddBlobClient(beaconNodeClient)
6566
}
6667
if config.BlobScanAPIEndpoint != "" {
6768
blobClientList.AddBlobClient(blob_client.NewBlobScanClient(config.BlobScanAPIEndpoint))

0 commit comments

Comments
 (0)