cmd/swarm/swarm-smoke: fix issue that loop variable capture in func (#17992)

pull/18012/head
Roc Yu 6 years ago committed by Anton Evangelatov
parent 54f650a3be
commit 3e1cfbae93
  1. 13
      cmd/swarm/swarm-smoke/feed_upload_and_sync.go

@ -13,16 +13,13 @@ import (
"sync" "sync"
"time" "time"
"github.com/pborman/uuid"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/swarm/multihash" "github.com/ethereum/go-ethereum/swarm/multihash"
"github.com/ethereum/go-ethereum/swarm/storage/feed" "github.com/ethereum/go-ethereum/swarm/storage/feed"
colorable "github.com/mattn/go-colorable" colorable "github.com/mattn/go-colorable"
"github.com/pborman/uuid"
cli "gopkg.in/urfave/cli.v1" cli "gopkg.in/urfave/cli.v1"
) )
@ -190,7 +187,7 @@ func cliFeedUploadAndSync(c *cli.Context) error {
for _, hex := range []string{topicHex, subTopicOnlyHex, mergedSubTopicHex} { for _, hex := range []string{topicHex, subTopicOnlyHex, mergedSubTopicHex} {
wg.Add(1) wg.Add(1)
ruid := uuid.New()[:8] ruid := uuid.New()[:8]
go func(endpoint string, ruid string) { go func(hex string, endpoint string, ruid string) {
for { for {
err := fetchFeed(hex, userHex, endpoint, dataHash, ruid) err := fetchFeed(hex, userHex, endpoint, dataHash, ruid)
if err != nil { if err != nil {
@ -200,7 +197,7 @@ func cliFeedUploadAndSync(c *cli.Context) error {
wg.Done() wg.Done()
return return
} }
}(endpoint, ruid) }(hex, endpoint, ruid)
} }
} }
@ -268,7 +265,7 @@ func cliFeedUploadAndSync(c *cli.Context) error {
for _, url := range []string{manifestWithTopic, manifestWithSubTopic, manifestWithMergedTopic} { for _, url := range []string{manifestWithTopic, manifestWithSubTopic, manifestWithMergedTopic} {
wg.Add(1) wg.Add(1)
ruid := uuid.New()[:8] ruid := uuid.New()[:8]
go func(endpoint string, ruid string) { go func(url string, endpoint string, ruid string) {
for { for {
err := fetch(url, endpoint, fileHash, ruid) err := fetch(url, endpoint, fileHash, ruid)
if err != nil { if err != nil {
@ -278,7 +275,7 @@ func cliFeedUploadAndSync(c *cli.Context) error {
wg.Done() wg.Done()
return return
} }
}(endpoint, ruid) }(url, endpoint, ruid)
} }
} }

Loading…
Cancel
Save