Browse Source

Make code smell better

pull/1962/head
ValarDragon 6 years ago
parent
commit
bd050c1d03
2 changed files with 21 additions and 13 deletions
  1. +5
    -13
      tools/tm-bench/main.go
  2. +16
    -0
      tools/tm-bench/transacter.go

+ 5
- 13
tools/tm-bench/main.go View File

@ -102,19 +102,6 @@ Examples:
)
// Wait until transacters have begun until we get the start time
for {
started := true
for _, t := range transacters {
for i := 0; i < t.Connections; i++ {
if !t.connsStarted[i] && !t.connsBroken[i] {
started = false
}
}
}
if started {
break
}
}
timeStart := time.Now()
logger.Info("Time last transacter started", "t", timeStart)
@ -270,6 +257,11 @@ func startTransacters(
transacters[i] = t
}
// Wait until all transacters have started firing txs
for _, t := range transacters {
t.WaitUntilAllConnectionsStartedFiringTxs()
}
return transacters
}


+ 16
- 0
tools/tm-bench/transacter.go View File

@ -86,6 +86,22 @@ func (t *transacter) Start() error {
return nil
}
// WaitUntilAllConnectionsStartedFiringTxs waits until all of this
// transacters connections have begun sending txs at the specified rate
func (t *transacter) WaitUntilAllConnectionsStartedFiringTxs() {
for {
started := true
for i := 0; i < t.Connections; i++ {
if !t.connsStarted[i] && !t.connsBroken[i] {
started = false
}
}
if started {
break
}
}
}
// Stop closes the connections.
func (t *transacter) Stop() {
t.stopped = true


Loading…
Cancel
Save