diff --git a/Dockerfile b/Dockerfile index d853bc3..5a60f8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,7 +64,7 @@ ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/entrypoint.sh"] # TODO: allow overriding below via env? CMD [ \ - "--saturn-orchestrator", "https://orchestrator.strn.pl/nodes/nearby", \ + "--saturn-orchestrator", "https://orchestrator.strn.pl/nodes/nearby?count=1000", \ "--saturn-logger", "https://twb3qukm2i654i3tnvx36char40aymqq.lambda-url.us-west-2.on.aws", \ "--kubo-rpc", "https://node0.delegate.ipfs.io", "--kubo-rpc", "https://node1.delegate.ipfs.io", "--kubo-rpc", "https://node2.delegate.ipfs.io", "--kubo-rpc", "https://node3.delegate.ipfs.io", \ "--gateway-port", "8081", \ diff --git a/blockstore.go b/blockstore.go index 9fd054c..c9f1a74 100644 --- a/blockstore.go +++ b/blockstore.go @@ -18,7 +18,7 @@ import ( const GetBlockTimeout = time.Second * 60 func newExchange(orchestrator, loggingEndpoint string) (exchange.Interface, error) { - b, err := newBlockStore(orchestrator, loggingEndpoint) + b, err := newCabooseBlockStore(orchestrator, loggingEndpoint) if err != nil { return nil, err } @@ -34,7 +34,7 @@ func (e *exchangeBsWrapper) GetBlock(ctx context.Context, c cid.Cid) (blocks.Blo defer cancel() if goLog.Level().Enabled(zapcore.DebugLevel) { - goLog.Debugw("block requested from saturn", "cid", c.String()) + goLog.Debugw("block requested from strn", "cid", c.String()) } return e.bstore.Get(ctx, c) @@ -66,15 +66,25 @@ func (e *exchangeBsWrapper) Close() error { var _ exchange.Interface = (*exchangeBsWrapper)(nil) -func newBlockStore(orchestrator, loggingEndpoint string) (blockstore.Blockstore, error) { - oe, err := url.Parse(orchestrator) - if err != nil { - return nil, err +func newCabooseBlockStore(orchestrator, loggingEndpoint string) (blockstore.Blockstore, error) { + var ( + orchURL *url.URL + loggURL *url.URL + err error + ) + + if orchestrator != "" { + orchURL, err = url.Parse(orchestrator) + if err != nil { + return nil, err + } } - le, err := url.Parse(loggingEndpoint) - if err != nil { - return nil, err + if loggingEndpoint != "" { + loggURL, err = url.Parse(loggingEndpoint) + if err != nil { + return nil, err + } } saturnClient := &http.Client{ @@ -87,16 +97,20 @@ func newBlockStore(orchestrator, loggingEndpoint string) (blockstore.Blockstore, }, } + saturnServiceClient := &http.Client{ + Transport: &withUserAgent{RoundTripper: http.DefaultTransport}, + } + return caboose.NewCaboose(&caboose.Config{ - OrchestratorEndpoint: *oe, - OrchestratorClient: http.DefaultClient, + OrchestratorEndpoint: orchURL, + OrchestratorClient: saturnServiceClient, - LoggingEndpoint: *le, - LoggingClient: http.DefaultClient, + LoggingEndpoint: *loggURL, + LoggingClient: saturnServiceClient, LoggingInterval: 5 * time.Second, DoValidation: true, PoolRefresh: 5 * time.Minute, - Client: saturnClient, + SaturnClient: saturnClient, }) } diff --git a/go.mod b/go.mod index 5a8973c..87d7080 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ipfs/bifrost-gateway go 1.19 require ( - github.com/filecoin-saturn/caboose v0.0.0-20230214221356-93567ae43731 + github.com/filecoin-saturn/caboose v0.0.0-20230216184950-d2749d3b8402 github.com/gogo/protobuf v1.3.2 github.com/hashicorp/golang-lru/v2 v2.0.1 github.com/ipfs/go-blockservice v0.5.0 @@ -35,7 +35,6 @@ require ( require ( github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/buraksezer/consistent v0.10.0 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect @@ -99,6 +98,7 @@ require ( github.com/prometheus/common v0.39.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb // indirect diff --git a/go.sum b/go.sum index cb5ee10..924cab5 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,6 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= -github.com/buraksezer/consistent v0.10.0 h1:hqBgz1PvNLC5rkWcEBVAL9dFMBWz6I0VgUCW25rrZlU= -github.com/buraksezer/consistent v0.10.0/go.mod h1:6BrVajWq7wbKZlTOUPs/XVfR8c0maujuPowduSpZqmw= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -132,8 +130,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/filecoin-saturn/caboose v0.0.0-20230214221356-93567ae43731 h1:lGAqwh3kPeBj4nSKpmZeBnuxsFWPYmq4J0cApl47I+Y= -github.com/filecoin-saturn/caboose v0.0.0-20230214221356-93567ae43731/go.mod h1:tMz/fmLkSoWwe7CHcnKvUo1WDbRWxstzHGDiVxUlU30= +github.com/filecoin-saturn/caboose v0.0.0-20230216184950-d2749d3b8402 h1:2jZeVT1FC9fAxNOq2g29i0hNrgTMlWq0AhqZn7TVtAI= +github.com/filecoin-saturn/caboose v0.0.0-20230216184950-d2749d3b8402/go.mod h1:+mNNW7G2QeSUsEM2e6Tk/rhAr1e2uruAygtYe+sSNAU= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= @@ -941,6 +939,8 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b h1:h+3JX2VoWTFuyQEo87pStk/a99dzIO1mM9KxIyLPGTU= +github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b/go.mod h1:/yeG0My1xr/u+HZrFQ1tOQQQQrOawfyMUH13ai5brBc= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= github.com/shurcooL/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0=