Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 8b10a88

Browse files
committed
[#1800] Remove APIRouter from IPFS routing stack
1 parent 3fd0924 commit 8b10a88

File tree

3 files changed

+12
-38
lines changed

3 files changed

+12
-38
lines changed

cmd/start.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,8 @@ func (x *Start) Execute(args []string) error {
407407
}
408408
var dhtRouting *dht.IpfsDHT
409409
for _, router := range tiered.Routers {
410-
if r, ok := router.(*ipfs.CachingRouter); ok {
411-
r.APIRouter().Start(torDialer)
412-
dhtRouting, err = r.DHT()
413-
if err != nil {
414-
return err
415-
}
410+
if r, ok := router.(*dht.IpfsDHT); ok {
411+
dhtRouting = r
416412
}
417413
}
418414
if dhtRouting == nil {

ipfs/config.go

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func PrepareIPFSConfig(r repo.Repo, routerAPIEndpoint string, testEnable, regtes
5555
}
5656

5757
func constructRouting(ctx context.Context, host p2phost.Host, dstore ds.Batching, validator record.Validator) (routing.IpfsRouting, error) {
58-
dhtRouting, err := dht.New(
58+
return dht.New(
5959
ctx, host,
6060
dhtopts.Datastore(dstore),
6161
dhtopts.Validator(validator),
@@ -64,12 +64,6 @@ func constructRouting(ctx context.Context, host p2phost.Host, dstore ds.Batching
6464
IPFSProtocolDHTMainnetLegacy,
6565
),
6666
)
67-
if err != nil {
68-
return nil, err
69-
}
70-
apiRouter := NewAPIRouter(routerCacheURI, dhtRouting.Validator)
71-
cachingRouter := NewCachingRouter(dhtRouting, &apiRouter)
72-
return cachingRouter, nil
7367
}
7468

7569
func constructRegtestRouting(ctx context.Context, host p2phost.Host, dstore ds.Batching, validator record.Validator) (routing.IpfsRouting, error) {
@@ -85,21 +79,13 @@ func constructRegtestRouting(ctx context.Context, host p2phost.Host, dstore ds.B
8579
}
8680

8781
func constructTestnetRouting(ctx context.Context, host p2phost.Host, dstore ds.Batching, validator record.Validator) (routing.IpfsRouting, error) {
88-
var (
89-
dhtRouting, err = dht.New(
90-
ctx, host,
91-
dhtopts.Datastore(dstore),
92-
dhtopts.Validator(validator),
93-
dhtopts.Protocols(
94-
IPFSProtocolKademliaTestnetOne,
95-
IPFSProtocolAppTestnetOne,
96-
),
97-
)
82+
return dht.New(
83+
ctx, host,
84+
dhtopts.Datastore(dstore),
85+
dhtopts.Validator(validator),
86+
dhtopts.Protocols(
87+
IPFSProtocolKademliaTestnetOne,
88+
IPFSProtocolAppTestnetOne,
89+
),
9890
)
99-
if err != nil {
100-
return nil, err
101-
}
102-
apiRouter := NewAPIRouter(routerCacheURI, dhtRouting.Validator)
103-
cachingRouter := NewCachingRouter(dhtRouting, &apiRouter)
104-
return cachingRouter, nil
10591
}

mobile/node.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838
"github.com/OpenBazaar/openbazaar-go/repo"
3939
"github.com/OpenBazaar/openbazaar-go/repo/db"
4040
"github.com/OpenBazaar/openbazaar-go/repo/migrations"
41-
"github.com/OpenBazaar/openbazaar-go/schema"
4241
apiSchema "github.com/OpenBazaar/openbazaar-go/schema"
4342
"github.com/OpenBazaar/openbazaar-go/storage/selfhosted"
4443
"github.com/OpenBazaar/openbazaar-go/wallet"
@@ -307,19 +306,12 @@ func NewNodeWithConfig(config *NodeConfig, password string, mnemonic string) (*N
307306
}
308307

309308
func constructMobileRouting(ctx context.Context, host p2phost.Host, dstore ds.Batching, validator record.Validator) (routing.IpfsRouting, error) {
310-
dhtRouting, err := dht.New(
309+
return dht.New(
311310
ctx, host,
312311
dhtopts.Client(true),
313312
dhtopts.Datastore(dstore),
314313
dhtopts.Validator(validator),
315314
)
316-
if err != nil {
317-
return nil, err
318-
}
319-
apiRouter := ipfs.NewAPIRouter(schema.IPFSCachingRouterDefaultURI, dhtRouting.Validator)
320-
apiRouter.Start(nil)
321-
cachingRouter := ipfs.NewCachingRouter(dhtRouting, &apiRouter)
322-
return cachingRouter, nil
323315
}
324316

325317
// startIPFSNode start the node

0 commit comments

Comments
 (0)