fix: add mode build param and change ipfs gateway accordingly
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
b5cc14f302
commit
86054875a4
5
Makefile
5
Makefile
|
@ -7,6 +7,7 @@ RELEASE_DIR := /tmp/release-$(RELEASE_TAG)
|
||||||
PRE_RELEASE := "1"
|
PRE_RELEASE := "1"
|
||||||
RELEASE_TYPE := $(shell if [ $(PRE_RELEASE) = "0" ] ; then echo release; else echo pre-release ; fi)
|
RELEASE_TYPE := $(shell if [ $(PRE_RELEASE) = "0" ] ; then echo release; else echo pre-release ; fi)
|
||||||
GOLANGCI_BINARY=golangci-lint
|
GOLANGCI_BINARY=golangci-lint
|
||||||
|
IPFS_GATEWAY_URL ?= https://ipfs.status.im/
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
|
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
|
||||||
detected_OS := Windows
|
detected_OS := Windows
|
||||||
|
@ -42,10 +43,12 @@ ENABLE_METRICS ?= true
|
||||||
BUILD_FLAGS ?= $(shell echo "-ldflags='\
|
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.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.IpfsGatewayURL=$(IPFS_GATEWAY_URL) \
|
||||||
-X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=$(ENABLE_METRICS)'")
|
-X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=$(ENABLE_METRICS)'")
|
||||||
BUILD_FLAGS_MOBILE ?= $(shell echo "-ldflags='\
|
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.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
|
networkid ?= StatusChain
|
||||||
gotest_extraflags =
|
gotest_extraflags =
|
||||||
|
|
|
@ -83,7 +83,7 @@ type GethStatusBackend struct {
|
||||||
|
|
||||||
// NewGethStatusBackend create a new GethStatusBackend instance
|
// NewGethStatusBackend create a new GethStatusBackend instance
|
||||||
func NewGethStatusBackend() *GethStatusBackend {
|
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 := &GethStatusBackend{}
|
||||||
backend.initialize()
|
backend.initialize()
|
||||||
|
|
|
@ -11,14 +11,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/multiformats/go-multibase"
|
|
||||||
"github.com/wealdtech/go-multicodec"
|
"github.com/wealdtech/go-multicodec"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"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
|
const maxRequestsPerSecond = 3
|
||||||
|
|
||||||
type taskResponse struct {
|
type taskResponse struct {
|
||||||
|
@ -133,7 +132,7 @@ func hashToCid(hash []byte) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return thisCID.StringOfBase(multibase.Base32)
|
return thisCID.Hash().B58String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeStringHash(input string) (string, error) {
|
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) {
|
func (d *Downloader) download(cid string, download bool) ([]byte, error) {
|
||||||
path := filepath.Join(d.ipfsDir, cid)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,3 +6,6 @@ var Version string
|
||||||
|
|
||||||
// GitCommit is a commit hash.
|
// GitCommit is a commit hash.
|
||||||
var GitCommit string
|
var GitCommit string
|
||||||
|
|
||||||
|
// IpfsGatewayURL is the Gateway URL to use for IPFS
|
||||||
|
var IpfsGatewayURL string
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
@ -568,7 +569,10 @@ func (api *API) ResourceURL(ctx context.Context, chainID uint64, username string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to obtain base36 representation")
|
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
|
return &URI{scheme, host, ""}, nil
|
||||||
case "ipns-ns":
|
case "ipns-ns":
|
||||||
id, offset := binary.Uvarint(data)
|
id, offset := binary.Uvarint(data)
|
||||||
|
|
|
@ -131,7 +131,7 @@ func TestResourceURL(t *testing.T) {
|
||||||
uri, err := api.ResourceURL(context.Background(), 1, "simpledapp.eth")
|
uri, err := api.ResourceURL(context.Background(), 1, "simpledapp.eth")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, "https", uri.Scheme)
|
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)
|
require.Equal(t, "", uri.Path)
|
||||||
|
|
||||||
uri, err = api.ResourceURL(context.Background(), 1, "swarm.eth")
|
uri, err = api.ResourceURL(context.Background(), 1, "swarm.eth")
|
||||||
|
|
|
@ -285,6 +285,7 @@ func (api *API) fetchStickerPacks(chainID uint64, resultChan chan<- *StickerPack
|
||||||
stickerPack, err := api.fetchPackData(stickerType, packID, true)
|
stickerPack, err := api.fetchPackData(stickerType, packID, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("Could not retrieve stickerpack data", "packID", packID, "error", err)
|
log.Warn("Could not retrieve stickerpack data", "packID", packID, "error", err)
|
||||||
|
errChan <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue