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

Commit 7ae20cf

Browse files
committed
Configure web relays from config file
1 parent 28af6e9 commit 7ae20cf

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

cmd/start.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ func (x *Start) Execute(args []string) error {
237237
log.Error("scan data sharing config:", err)
238238
return err
239239
}
240+
webRelays, err := schema.GetWebRelays(configFile)
241+
if err != nil {
242+
log.Error("scan web relays config:", err)
243+
return err
244+
}
240245
dropboxToken, err := schema.GetDropboxApiToken(configFile)
241246
if err != nil {
242247
log.Error("scan dropbox api token:", err)
@@ -578,10 +583,12 @@ func (x *Start) Execute(args []string) error {
578583
subscriber := ipfs.NewPubsubSubscriber(context.Background(), nd.PeerHost, nd.Routing, nd.Repo.Datastore(), nd.PubSub)
579584
ps := ipfs.Pubsub{Publisher: publisher, Subscriber: subscriber}
580585

581-
var rootHash string
582-
if cachedIPNSRecord != nil {
583-
rootHash = string(cachedIPNSRecord.Value)
584-
}
586+
var rootHash string
587+
if cachedIPNSRecord != nil {
588+
rootHash = string(cachedIPNSRecord.Value)
589+
}
590+
591+
wm := obnet.NewWebRelayManager(webRelays, identity.PeerID)
585592

586593
// OpenBazaar node setup
587594
core.Node = &core.OpenBazaarNode{
@@ -595,6 +602,7 @@ func (x *Start) Execute(args []string) error {
595602
OfflineMessageFailoverTimeout: 30 * time.Second,
596603
Pubsub: ps,
597604
PushNodes: pushNodes,
605+
WebRelayManager: wm,
598606
RegressionTestEnable: x.Regtest,
599607
RepoPath: repoPath,
600608
RootHash: rootHash,

mobile/node.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ func NewNodeWithConfig(config *NodeConfig, password string, mnemonic string) (*N
151151
return nil, err
152152
}
153153

154+
webRelays, err := apiSchema.GetWebRelays(configFile)
155+
if err != nil {
156+
return nil, err
157+
}
158+
154159
walletsConfig, err := apiSchema.GetWalletsConfig(configFile)
155160
if err != nil {
156161
return nil, err
@@ -275,6 +280,8 @@ func NewNodeWithConfig(config *NodeConfig, password string, mnemonic string) (*N
275280
pushNodes = append(pushNodes, p)
276281
}
277282

283+
wm := obnet.NewWebRelayManager(webRelays, identity.PeerID)
284+
278285
// OpenBazaar node setup
279286
node := &core.OpenBazaarNode{
280287
BanManager: bm,
@@ -283,6 +290,7 @@ func NewNodeWithConfig(config *NodeConfig, password string, mnemonic string) (*N
283290
Multiwallet: mw,
284291
OfflineMessageFailoverTimeout: 5 * time.Second,
285292
PushNodes: pushNodes,
293+
WebRelayManager: wm,
286294
RepoPath: config.RepoPath,
287295
UserAgent: core.USERAGENT,
288296
IPNSQuorumSize: uint(ipnsExtraConfig.DHTQuorumSize),

0 commit comments

Comments
 (0)