Skip to content

Commit

Permalink
fix: configure duplicate StorageMiners (#167)
Browse files Browse the repository at this point in the history
Co-authored-by: 一页素书 <2931107265@qq.com>
  • Loading branch information
diwufeiwen and ta0li authored Jul 15, 2022
1 parent 91ae1d1 commit ce1375e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cmd/venus-market/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ func flagData(cctx *cli.Context, cfg *config.MarketConfig) error {
}

if cctx.IsSet(MinerListFlag.Name) {
storageMiners := make(map[config.Address]struct{}, 0)
for _, storageMiner := range cfg.StorageMiners {
if _, ok := storageMiners[storageMiner.Addr]; !ok {
storageMiners[storageMiner.Addr] = struct{}{}
}
}

addrStrs := cctx.StringSlice(MinerListFlag.Name)
for _, miners := range addrStrs {
addrStr := strings.Split(miners, ":")
Expand All @@ -259,11 +266,13 @@ func flagData(cctx *cli.Context, cfg *config.MarketConfig) error {
if len(addrStr) >= 2 {
account = addrStr[1]
}
// todo 这里是追加不是替换
cfg.StorageMiners = append(cfg.StorageMiners, config.User{
Addr: config.Address(addr),
Account: account,
})

if _, ok := storageMiners[config.Address(addr)]; !ok {
cfg.StorageMiners = append(cfg.StorageMiners, config.User{
Addr: config.Address(addr),
Account: account,
})
}
}
}

Expand Down

0 comments on commit ce1375e

Please sign in to comment.