Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cmd/swarm/swarm-smoke/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
allhosts string
hosts []string
filesize int
syncDelay int
syncDelay bool
inputSeed int
httpPort int
wsPort int
Expand Down Expand Up @@ -87,10 +87,9 @@ func main() {
Usage: "file size for generated random file in KB",
Destination: &filesize,
},
cli.IntFlag{
cli.BoolFlag{
Name: "sync-delay",
Value: 5,
Usage: "duration of delay in seconds to wait for content to be synced",
Usage: "wait for content to be synced",
Destination: &syncDelay,
},
cli.IntFlag{
Expand Down
8 changes: 6 additions & 2 deletions cmd/swarm/swarm-smoke/sliding_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ outer:
return err
}

log.Info("uploaded successfully", "hash", hash, "digest", fmt.Sprintf("%x", fhash), "sleeping", syncDelay)
log.Info("uploaded successfully", "hash", hash, "digest", fmt.Sprintf("%x", fhash), "wait for sync", syncDelay)
hashes = append(hashes, uploadResult{hash: hash, digest: fhash})
time.Sleep(time.Duration(syncDelay) * time.Second)

if syncDelay {
waitToSync()
}

uploadedBytes += filesize * 1000
q := make(chan struct{}, 1)
d := make(chan struct{})
Expand Down
16 changes: 10 additions & 6 deletions cmd/swarm/swarm-smoke/upload_and_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ func getBzzAddrFromHost(client *rpc.Client) (string, error) {
// we make an ugly assumption about the output format of the hive.String() method
// ideally we should replace this with an API call that returns the bzz addr for a given host,
// but this also works for now (provided we don't change the hive.String() method, which we haven't in some time
return strings.Split(strings.Split(hive, "\n")[3], " ")[10], nil
ss := strings.Split(strings.Split(hive, "\n")[3], " ")
return ss[len(ss)-1], nil
}

// checkChunksVsMostProxHosts is checking:
Expand Down Expand Up @@ -284,13 +285,16 @@ func uploadAndSync(c *cli.Context, randomBytes []byte) error {

log.Info("uploaded successfully", "hash", hash, "took", t2, "digest", fmt.Sprintf("%x", fhash))

waitToSync()
// wait to sync and log chunks before fetch attempt, only if syncDelay is set to true
if syncDelay {
waitToSync()

log.Debug("chunks before fetch attempt", "hash", hash)
log.Debug("chunks before fetch attempt", "hash", hash)

err = trackChunks(randomBytes, false)
if err != nil {
log.Error(err.Error())
err = trackChunks(randomBytes, false)
if err != nil {
log.Error(err.Error())
}
}

if onlyUpload {
Expand Down