diff --git a/clients/blocksdata/r2_client.go b/clients/blocksdata/r2_client.go index 044d9edb..04072772 100644 --- a/clients/blocksdata/r2_client.go +++ b/clients/blocksdata/r2_client.go @@ -2,6 +2,7 @@ package blocksdata import ( "bytes" + "compress/gzip" "encoding/json" "fmt" "io" @@ -9,7 +10,6 @@ import ( "net/url" "time" - "github.com/andybalholm/brotli" backoff "github.com/cenkalti/backoff/v4" "github.com/forta-network/forta-core-go/protocol" "github.com/forta-network/forta-core-go/utils/httpclient" @@ -102,11 +102,18 @@ func (c *blocksDataClient) GetBlocksData(bucket int64) (_ *protocol.BlocksData, return err } + defer resp.Body.Close() + if resp.StatusCode != 200 { return fmt.Errorf("unexpected status code: %d", resp.StatusCode) } - b, err := io.ReadAll(brotli.NewReader(resp.Body)) + gzipReader, err := gzip.NewReader(resp.Body) + if err != nil { + return err + } + + b, err := io.ReadAll(gzipReader) if err != nil { return err } diff --git a/go.mod b/go.mod index fd31eba8..4f1f0eca 100644 --- a/go.mod +++ b/go.mod @@ -39,11 +39,10 @@ require ( replace github.com/docker/docker => github.com/moby/moby v20.10.25+incompatible require ( - github.com/andybalholm/brotli v1.1.0 github.com/cenkalti/backoff/v4 v4.1.3 github.com/docker/docker v1.6.2 github.com/docker/go-connections v0.4.0 - github.com/forta-network/forta-core-go v0.0.0-20240315154515-c71e1f3bd5e2 + github.com/forta-network/forta-core-go v0.0.0-20240401084734-5e73299ce04c github.com/prometheus/client_golang v1.14.0 github.com/prometheus/client_model v0.3.0 github.com/prometheus/common v0.39.0 diff --git a/go.sum b/go.sum index 02c846d2..f4af1e58 100644 --- a/go.sum +++ b/go.sum @@ -109,8 +109,6 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0= @@ -331,8 +329,8 @@ github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe 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= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/forta-network/forta-core-go v0.0.0-20240315154515-c71e1f3bd5e2 h1:v+snSZVsMUPtPX6pI5oxULTWiAfJ1igeE0Iqilma7/Y= -github.com/forta-network/forta-core-go v0.0.0-20240315154515-c71e1f3bd5e2/go.mod h1:iNehCWOypwVeO8b1GKmsrEWReHTvO5qw8SsGvZsBINo= +github.com/forta-network/forta-core-go v0.0.0-20240401084734-5e73299ce04c h1:nlbe6zfWzQD/V4iEeL6ggB2qWr1SoOZQZLV5uCJIN5U= +github.com/forta-network/forta-core-go v0.0.0-20240401084734-5e73299ce04c/go.mod h1:iNehCWOypwVeO8b1GKmsrEWReHTvO5qw8SsGvZsBINo= github.com/forta-network/go-multicall v0.0.0-20230609185354-1436386c6707 h1:f6I7K43i2m6AwHSsDxh0Mf3qFzYt8BKnabSl/zGFmh0= github.com/forta-network/go-multicall v0.0.0-20230609185354-1436386c6707/go.mod h1:nqTUF1REklpWLZ/M5HfzqhSHNz4dPVKzJvbLziqTZpw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=