Skip to content

Commit

Permalink
modify config atomically
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed Jul 7, 2021
1 parent 6b014f5 commit 68ab7b4
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions itests/kit/ensemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,35 +416,34 @@ func (n *Ensemble) Start() *Ensemble {
lr, err := r.Lock(repo.StorageMiner)
require.NoError(n.t, err)

err = lr.SetConfig(func(raw interface{}) {
cfg := raw.(*config.StorageMiner)
cfg.Common.API.RemoteListenAddress = m.RemoteListener.Addr().String()
cfg.Subsystems.EnableStorageMarket = m.options.subsystems.Has(SStorageMarket)
cfg.Subsystems.EnableMining = m.options.subsystems.Has(SMining)
cfg.Subsystems.EnableSealing = m.options.subsystems.Has(SSealing)
cfg.Subsystems.EnableSectorStorage = m.options.subsystems.Has(SSectorStorage)

if m.options.mainMiner != nil {
token, err := m.options.mainMiner.FullNode.AuthNew(ctx, api.AllPermissions)
require.NoError(n.t, err)

cfg.Subsystems.SectorIndexApiInfo = fmt.Sprintf("%s:%s", token, m.options.mainMiner.ListenAddr)
cfg.Subsystems.SealerApiInfo = fmt.Sprintf("%s:%s", token, m.options.mainMiner.ListenAddr)

fmt.Println("config for market node, setting SectorIndexApiInfo to: ", cfg.Subsystems.SectorIndexApiInfo)
fmt.Println("config for market node, setting SealerApiInfo to: ", cfg.Subsystems.SealerApiInfo)
}
})
require.NoError(n.t, err)

c, err := lr.Config()
require.NoError(n.t, err)

cfg, ok := c.(*config.StorageMiner)
if !ok {
n.t.Fatalf("invalid config from repo, got: %T", c)
}
cfg.Common.API.RemoteListenAddress = m.RemoteListener.Addr().String()
cfg.Subsystems.EnableStorageMarket = m.options.subsystems.Has(SStorageMarket)
cfg.Subsystems.EnableMining = m.options.subsystems.Has(SMining)
cfg.Subsystems.EnableSealing = m.options.subsystems.Has(SSealing)
cfg.Subsystems.EnableSectorStorage = m.options.subsystems.Has(SSectorStorage)

if m.options.mainMiner != nil {
token, err := m.options.mainMiner.FullNode.AuthNew(ctx, api.AllPermissions)
require.NoError(n.t, err)

cfg.Subsystems.SectorIndexApiInfo = fmt.Sprintf("%s:%s", token, m.options.mainMiner.ListenAddr)
cfg.Subsystems.SealerApiInfo = fmt.Sprintf("%s:%s", token, m.options.mainMiner.ListenAddr)

fmt.Println("config for market node, setting SectorIndexApiInfo to: ", cfg.Subsystems.SectorIndexApiInfo)
fmt.Println("config for market node, setting SealerApiInfo to: ", cfg.Subsystems.SealerApiInfo)
}

err = lr.SetConfig(func(raw interface{}) {
rcfg := raw.(*config.StorageMiner)
*rcfg = *cfg
})
require.NoError(n.t, err)

ks, err := lr.KeyStore()
require.NoError(n.t, err)
Expand Down

0 comments on commit 68ab7b4

Please sign in to comment.