Make code smell better

This commit is contained in:
ValarDragon 2018-07-12 12:42:26 -07:00
parent 7a7f5782bc
commit bd050c1d03
2 changed files with 21 additions and 13 deletions

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
}

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