fix: add mode build param and change ipfs gateway accordingly

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Richard Ramos 2022-08-11 10:27:25 -04:00 committed by Jakub Sokołowski
parent b5cc14f302
commit 86054875a4
No known key found for this signature in database
GPG Key ID: 09AA5403E54D9931
8 changed files with 19 additions and 9 deletions

View File

@ -7,6 +7,7 @@ RELEASE_DIR := /tmp/release-$(RELEASE_TAG)
PRE_RELEASE := "1"
RELEASE_TYPE := $(shell if [ $(PRE_RELEASE) = "0" ] ; then echo release; else echo pre-release ; fi)
GOLANGCI_BINARY=golangci-lint
IPFS_GATEWAY_URL ?= https://ipfs.status.im/
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
detected_OS := Windows
@ -42,10 +43,12 @@ ENABLE_METRICS ?= true
BUILD_FLAGS ?= $(shell echo "-ldflags='\
-X github.com/status-im/status-go/params.Version=$(RELEASE_TAG:v%=%) \
-X github.com/status-im/status-go/params.GitCommit=$(GIT_COMMIT) \
-X github.com/status-im/status-go/params.IpfsGatewayURL=$(IPFS_GATEWAY_URL) \
-X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=$(ENABLE_METRICS)'")
BUILD_FLAGS_MOBILE ?= $(shell echo "-ldflags='\
-X github.com/status-im/status-go/params.Version=$(RELEASE_TAG:v%=%) \
-X github.com/status-im/status-go/params.GitCommit=$(GIT_COMMIT)'")
-X github.com/status-im/status-go/params.GitCommit=$(GIT_COMMIT) \
-X github.com/status-im/status-go/params.IPFS_GATEWAY_URL=$(IPFS_GATEWAY_URL)'")
networkid ?= StatusChain
gotest_extraflags =

View File

@ -1 +1 @@
0.106.3
0.107.0

View File

@ -83,7 +83,7 @@ type GethStatusBackend struct {
// NewGethStatusBackend create a new GethStatusBackend instance
func NewGethStatusBackend() *GethStatusBackend {
defer log.Info("Status backend initialized", "backend", "geth", "version", params.Version, "commit", params.GitCommit)
defer log.Info("Status backend initialized", "backend", "geth", "version", params.Version, "commit", params.GitCommit, "IpfsGatewayURL", params.IpfsGatewayURL)
backend := &GethStatusBackend{}
backend.initialize()

View File

@ -11,14 +11,13 @@ import (
"time"
"github.com/ipfs/go-cid"
"github.com/multiformats/go-multibase"
"github.com/wealdtech/go-multicodec"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/params"
)
const infuraAPIURL = "https://ipfs.infura.io:5001/api/v0/cat?arg="
const maxRequestsPerSecond = 3
type taskResponse struct {
@ -133,7 +132,7 @@ func hashToCid(hash []byte) (string, error) {
return "", err
}
return thisCID.StringOfBase(multibase.Base32)
return thisCID.Hash().B58String(), nil
}
func decodeStringHash(input string) (string, error) {
@ -198,7 +197,7 @@ func (d *Downloader) exists(cid string) (bool, []byte, error) {
func (d *Downloader) download(cid string, download bool) ([]byte, error) {
path := filepath.Join(d.ipfsDir, cid)
req, err := http.NewRequest(http.MethodPost, infuraAPIURL+cid, nil)
req, err := http.NewRequest(http.MethodGet, params.IpfsGatewayURL+cid, nil)
if err != nil {
return nil, err
}

View File

@ -6,3 +6,6 @@ var Version string
// GitCommit is a commit hash.
var GitCommit string
// IpfsGatewayURL is the Gateway URL to use for IPFS
var IpfsGatewayURL string

View File

@ -6,6 +6,7 @@ import (
"encoding/hex"
"fmt"
"math/big"
"net/url"
"strings"
"sync"
@ -568,7 +569,10 @@ func (api *API) ResourceURL(ctx context.Context, chainID uint64, username string
if err != nil {
return nil, errors.Wrap(err, "failed to obtain base36 representation")
}
host := str + ".ipfs.infura-ipfs.io/"
parsedURL, _ := url.Parse(params.IpfsGatewayURL)
// Remove scheme from the url
host := parsedURL.Hostname() + parsedURL.Path + str
return &URI{scheme, host, ""}, nil
case "ipns-ns":
id, offset := binary.Uvarint(data)

View File

@ -131,7 +131,7 @@ func TestResourceURL(t *testing.T) {
uri, err := api.ResourceURL(context.Background(), 1, "simpledapp.eth")
require.NoError(t, err)
require.Equal(t, "https", uri.Scheme)
require.Equal(t, "bafybeidzlqpkbtvpjtxnzgew6ffxhozq5f4ojbk64iq3tjl7lkjue2biby.ipfs.infura-ipfs.io/", uri.Host)
require.Equal(t, "bafybeidzlqpkbtvpjtxnzgew6ffxhozq5f4ojbk64iq3tjl7lkjue2biby", uri.Host)
require.Equal(t, "", uri.Path)
uri, err = api.ResourceURL(context.Background(), 1, "swarm.eth")

View File

@ -285,6 +285,7 @@ func (api *API) fetchStickerPacks(chainID uint64, resultChan chan<- *StickerPack
stickerPack, err := api.fetchPackData(stickerType, packID, true)
if err != nil {
log.Warn("Could not retrieve stickerpack data", "packID", packID, "error", err)
errChan <- err
return
}