|
@ -4,16 +4,16 @@ import ( |
|
|
"flag" |
|
|
"flag" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"os" |
|
|
"os" |
|
|
|
|
|
"os/signal" |
|
|
"strings" |
|
|
"strings" |
|
|
"sync" |
|
|
"sync" |
|
|
|
|
|
"syscall" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
"github.com/go-kit/kit/log/term" |
|
|
"github.com/go-kit/kit/log/term" |
|
|
|
|
|
|
|
|
"github.com/tendermint/tendermint/libs/log" |
|
|
"github.com/tendermint/tendermint/libs/log" |
|
|
tmrpc "github.com/tendermint/tendermint/rpc/client" |
|
|
tmrpc "github.com/tendermint/tendermint/rpc/client" |
|
|
"os/signal" |
|
|
|
|
|
"syscall" |
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
var logger = log.NewNopLogger() |
|
|
var logger = log.NewNopLogger() |
|
@ -53,8 +53,7 @@ Examples: |
|
|
|
|
|
|
|
|
if verbose { |
|
|
if verbose { |
|
|
if outputFormat == "json" { |
|
|
if outputFormat == "json" { |
|
|
fmt.Fprintln(os.Stderr, "Verbose mode not supported with json output.") |
|
|
|
|
|
os.Exit(1) |
|
|
|
|
|
|
|
|
printErrorAndExit("Verbose mode not supported with json output.") |
|
|
} |
|
|
} |
|
|
// Color errors red
|
|
|
// Color errors red
|
|
|
colorFn := func(keyvals ...interface{}) term.FgBgColor { |
|
|
colorFn := func(keyvals ...interface{}) term.FgBgColor { |
|
@ -71,21 +70,13 @@ Examples: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if txSize < 40 { |
|
|
if txSize < 40 { |
|
|
fmt.Fprintln( |
|
|
|
|
|
os.Stderr, |
|
|
|
|
|
"The size of a transaction must be greater than or equal to 40.", |
|
|
|
|
|
) |
|
|
|
|
|
os.Exit(1) |
|
|
|
|
|
|
|
|
printErrorAndExit("The size of a transaction must be greater than or equal to 40.") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if broadcastTxMethod != "async" && |
|
|
if broadcastTxMethod != "async" && |
|
|
broadcastTxMethod != "sync" && |
|
|
broadcastTxMethod != "sync" && |
|
|
broadcastTxMethod != "commit" { |
|
|
broadcastTxMethod != "commit" { |
|
|
fmt.Fprintln( |
|
|
|
|
|
os.Stderr, |
|
|
|
|
|
"broadcast-tx-method should be either 'sync', 'async' or 'commit'.", |
|
|
|
|
|
) |
|
|
|
|
|
os.Exit(1) |
|
|
|
|
|
|
|
|
printErrorAndExit("broadcast-tx-method should be either 'sync', 'async' or 'commit'.") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var ( |
|
|
var ( |
|
@ -103,10 +94,10 @@ Examples: |
|
|
"broadcast_tx_"+broadcastTxMethod, |
|
|
"broadcast_tx_"+broadcastTxMethod, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
//catch Interrupt and quit tm-bench
|
|
|
|
|
|
|
|
|
// Quit when interrupted or received SIGTERM.
|
|
|
|
|
|
c := make(chan os.Signal, 1) |
|
|
|
|
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM) |
|
|
go func() { |
|
|
go func() { |
|
|
c := make(chan os.Signal, 1) |
|
|
|
|
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM) |
|
|
|
|
|
for sig := range c { |
|
|
for sig := range c { |
|
|
fmt.Printf("captured %v, exiting...\n", sig) |
|
|
fmt.Printf("captured %v, exiting...\n", sig) |
|
|
for _, t := range transacters { |
|
|
for _, t := range transacters { |
|
@ -116,7 +107,7 @@ Examples: |
|
|
} |
|
|
} |
|
|
}() |
|
|
}() |
|
|
|
|
|
|
|
|
// Wait until transacters have begun until we get the start time
|
|
|
|
|
|
|
|
|
// Wait until transacters have begun until we get the start time.
|
|
|
timeStart := time.Now() |
|
|
timeStart := time.Now() |
|
|
logger.Info("Time last transacter started", "t", timeStart) |
|
|
logger.Info("Time last transacter started", "t", timeStart) |
|
|
|
|
|
|
|
@ -143,8 +134,7 @@ Examples: |
|
|
durationInt, |
|
|
durationInt, |
|
|
) |
|
|
) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Fprintln(os.Stderr, err) |
|
|
|
|
|
os.Exit(1) |
|
|
|
|
|
|
|
|
printErrorAndExit(err.Error()) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
printStatistics(stats, outputFormat) |
|
|
printStatistics(stats, outputFormat) |
|
@ -196,3 +186,8 @@ func startTransacters( |
|
|
|
|
|
|
|
|
return transacters |
|
|
return transacters |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func printErrorAndExit(err string) { |
|
|
|
|
|
fmt.Fprintln(os.Stderr, err) |
|
|
|
|
|
os.Exit(1) |
|
|
|
|
|
} |