Skip to content

Commit 8b4390b

Browse files
Merge pull request ipfs/kubo#4610 from ipfs/gx/update-1m7019
mega update This commit was moved from ipfs/kubo@b386088
2 parents adf3659 + a2bc6ae commit 8b4390b

File tree

6 files changed

+34
-28
lines changed

6 files changed

+34
-28
lines changed

gateway/core/corehttp/commands.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
path "github.com/ipfs/go-ipfs/path"
1616
config "github.com/ipfs/go-ipfs/repo/config"
1717

18-
cmds "gx/ipfs/QmUEB5nT4LG3TkUd5mkHrfRESUSgaUD4r7jSAYvvPeuWT9/go-ipfs-cmds"
19-
cmdsHttp "gx/ipfs/QmUEB5nT4LG3TkUd5mkHrfRESUSgaUD4r7jSAYvvPeuWT9/go-ipfs-cmds/http"
18+
cmds "gx/ipfs/QmPq2D7Yoyev7yeMuMnkEYBqmQuUu5kb91UXPPoiik1Xyp/go-ipfs-cmds"
19+
cmdsHttp "gx/ipfs/QmPq2D7Yoyev7yeMuMnkEYBqmQuUu5kb91UXPPoiik1Xyp/go-ipfs-cmds/http"
2020
)
2121

2222
var (

gateway/core/corehttp/corehttp.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
"time"
1212

1313
core "github.com/ipfs/go-ipfs/core"
14+
manet "gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net"
1415
"gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
15-
manet "gx/ipfs/QmSGL5Uoa6gKHgBBwQG8u1CWKUC8ZnwaZiLgFVTFBR2bxr/go-multiaddr-net"
1616
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
17-
ma "gx/ipfs/QmW8s4zTsUoX1Q6CeYxVKPyqSKbF7H1YDUyTostBtZ8DaG/go-multiaddr"
17+
ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr"
1818
)
1919

2020
var log = logging.Logger("core/server")

gateway/core/corehttp/gateway.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
coreapi "github.com/ipfs/go-ipfs/core/coreapi"
1010
config "github.com/ipfs/go-ipfs/repo/config"
1111

12-
id "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/protocol/identify"
12+
id "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/protocol/identify"
1313
)
1414

1515
type GatewayConfig struct {

gateway/core/corehttp/gateway_handler.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import (
2323
ft "github.com/ipfs/go-ipfs/unixfs"
2424
uio "github.com/ipfs/go-ipfs/unixfs/io"
2525

26-
node "gx/ipfs/QmNwUEK7QbwSqyKBu3mMtToo8SUc6wQJ7gdZq4gGGJqfnf/go-ipld-format"
27-
routing "gx/ipfs/QmPCGUjMRuBcPybZFpjhzpifwPP9wPRoiy5geTQKU4vqWA/go-libp2p-routing"
2826
humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize"
29-
multibase "gx/ipfs/QmafgXF3u3QSWErQoZ2URmQp5PFG384htoE7J338nS2H7T/go-multibase"
30-
cid "gx/ipfs/QmeSrf6pzut73u6zLQkRFQ3ygt3k6XFT2kjdYP8Tnkwwyg/go-cid"
27+
routing "gx/ipfs/QmRijoA6zGS98ELTDbGsLWPZbVotYsGbjp3RbXcKCYBeon/go-libp2p-routing"
28+
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
29+
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
30+
multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase"
3131
)
3232

3333
const (
@@ -53,7 +53,7 @@ func newGatewayHandler(n *core.IpfsNode, c GatewayConfig, api coreiface.CoreAPI)
5353
}
5454

5555
// TODO(cryptix): find these helpers somewhere else
56-
func (i *gatewayHandler) newDagFromReader(r io.Reader) (node.Node, error) {
56+
func (i *gatewayHandler) newDagFromReader(r io.Reader) (ipld.Node, error) {
5757
// TODO(cryptix): change and remove this helper once PR1136 is merged
5858
// return ufs.AddFromReader(i.node, r.Body)
5959
return importer.BuildDagFromReader(
@@ -316,7 +316,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
316316

317317
// storage for directory listing
318318
var dirListing []directoryItem
319-
dirr.ForEachLink(ctx, func(link *node.Link) error {
319+
dirr.ForEachLink(ctx, func(link *ipld.Link) error {
320320
// See comment above where originalUrlPath is declared.
321321
di := directoryItem{humanize.Bytes(link.Size), link.Name, gopath.Join(originalUrlPath, link.Name)}
322322
dirListing = append(dirListing, di)
@@ -425,7 +425,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
425425
return
426426
}
427427

428-
var newnode node.Node
428+
var newnode ipld.Node
429429
if rsegs[len(rsegs)-1] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" {
430430
newnode = ft.EmptyDirNode()
431431
} else {
@@ -474,7 +474,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
474474
return
475475
}
476476

477-
nnode, err := e.Finalize(i.node.DAG)
477+
nnode, err := e.Finalize(ctx, i.node.DAG)
478478
if err != nil {
479479
webError(w, "putHandler: could not get node", err, http.StatusInternalServerError)
480480
return
@@ -498,11 +498,11 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
498498
// object set-data case
499499
pbnd.SetData(pbnewnode.Data())
500500

501-
newcid, err = i.node.DAG.Add(pbnd)
501+
newcid = pbnd.Cid()
502+
err = i.node.DAG.Add(ctx, pbnd)
502503
if err != nil {
503504
nnk := newnode.Cid()
504-
rk := pbnd.Cid()
505-
webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.String(), rk.String()), err, http.StatusInternalServerError)
505+
webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.String(), newcid.String()), err, http.StatusInternalServerError)
506506
return
507507
}
508508
default:
@@ -561,7 +561,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
561561

562562
var newnode *dag.ProtoNode = pbnd
563563
for j := len(pathNodes) - 2; j >= 0; j-- {
564-
if _, err := i.node.DAG.Add(newnode); err != nil {
564+
if err := i.node.DAG.Add(ctx, newnode); err != nil {
565565
webError(w, "Could not add node", err, http.StatusInternalServerError)
566566
return
567567
}
@@ -579,7 +579,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
579579
}
580580
}
581581

582-
if _, err := i.node.DAG.Add(newnode); err != nil {
582+
if err := i.node.DAG.Add(ctx, newnode); err != nil {
583583
webError(w, "Could not add root node", err, http.StatusInternalServerError)
584584
return
585585
}

gateway/core/corehttp/gateway_test.go

+13-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
config "github.com/ipfs/go-ipfs/repo/config"
2020
ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2"
2121

22-
id "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/protocol/identify"
22+
id "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/protocol/identify"
2323
ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto"
2424
)
2525

@@ -55,7 +55,7 @@ func (m mockNamesys) GetResolver(subs string) (namesys.Resolver, bool) {
5555
func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) {
5656
c := config.Config{
5757
Identity: config.Identity{
58-
PeerID: "Qmfoo", // required by offline node
58+
PeerID: "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe", // required by offline node
5959
},
6060
}
6161
r := &repo.Mock{
@@ -178,6 +178,9 @@ func TestGatewayGet(t *testing.T) {
178178
}
179179

180180
func TestIPNSHostnameRedirect(t *testing.T) {
181+
ctx, cancel := context.WithCancel(context.Background())
182+
defer cancel()
183+
181184
ns := mockNamesys{}
182185
ts, n := newTestServerAndNode(t, ns)
183186
t.Logf("test server url: %s", ts.URL)
@@ -199,12 +202,12 @@ func TestIPNSHostnameRedirect(t *testing.T) {
199202
t.Fatal(err)
200203
}
201204

202-
_, err = n.DAG.Add(dagn2)
205+
err = n.DAG.Add(ctx, dagn2)
203206
if err != nil {
204207
t.Fatal(err)
205208
}
206209

207-
_, err = n.DAG.Add(dagn1)
210+
err = n.DAG.Add(ctx, dagn1)
208211
if err != nil {
209212
t.Fatal(err)
210213
}
@@ -262,6 +265,9 @@ func TestIPNSHostnameRedirect(t *testing.T) {
262265
}
263266

264267
func TestIPNSHostnameBacklinks(t *testing.T) {
268+
ctx, cancel := context.WithCancel(context.Background())
269+
defer cancel()
270+
265271
ns := mockNamesys{}
266272
ts, n := newTestServerAndNode(t, ns)
267273
t.Logf("test server url: %s", ts.URL)
@@ -286,15 +292,15 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
286292
t.Fatal(err)
287293
}
288294

289-
_, err = n.DAG.Add(dagn3)
295+
err = n.DAG.Add(ctx, dagn3)
290296
if err != nil {
291297
t.Fatal(err)
292298
}
293-
_, err = n.DAG.Add(dagn2)
299+
err = n.DAG.Add(ctx, dagn2)
294300
if err != nil {
295301
t.Fatal(err)
296302
}
297-
_, err = n.DAG.Add(dagn1)
303+
err = n.DAG.Add(ctx, dagn1)
298304
if err != nil {
299305
t.Fatal(err)
300306
}

gateway/core/corehttp/metrics_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77

88
core "github.com/ipfs/go-ipfs/core"
99

10-
inet "gx/ipfs/QmU4vCDZTPLDqSDKguWbHCiUe46mZUtmM2g2suBZ9NE8ko/go-libp2p-net"
11-
testutil "gx/ipfs/QmZTcPxK6VqrwY94JpKZPvEqAZ6tEr1rLrpcqJbbRZbg2V/go-libp2p-netutil"
12-
bhost "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/host/basic"
10+
bhost "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/host/basic"
11+
inet "gx/ipfs/QmQm7WmgYCa4RSz76tKEYpRjApjnRw8ZTUVQC15b8JM4a2/go-libp2p-net"
12+
testutil "gx/ipfs/QmWUugnJBbcuin8qdfiCYKAsNkG8NeDLhzoBqRaqXhAHd4/go-libp2p-netutil"
1313
)
1414

1515
// This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect

0 commit comments

Comments
 (0)