Commit 8236fa25 authored by 李伟@五瓣科技's avatar 李伟@五瓣科技

add web static dir

parent 46fe699c
......@@ -19,6 +19,7 @@ var (
rate, sendPeriod, count, expectedTime int
websocketAddr, redisAddr, redisPasswd string
sendTxPrivateKey string
webStaticDir string
)
func init() {
......@@ -31,6 +32,7 @@ func init() {
rootCmd.PersistentFlags().StringVar(&redisAddr, "redisAddr", "127.0.0.1:6379", "commit the original txs to the redis queue")
rootCmd.PersistentFlags().StringVar(&redisPasswd, "redisPasswd", "redis20220217", "redis password")
rootCmd.PersistentFlags().StringVar(&sendTxPrivateKey, "sendTxPrivateKey", "a1994419e9b06a7b27e8d094840ae26a6b7806633bb8be55a1a835f1620d8cec", "send tx to the chain with the private key")
rootCmd.PersistentFlags().StringVar(&webStaticDir, "webStaticDir", "./", "send tx to the chain with the private key")
}
var rootCmd = &cobra.Command{
......
......@@ -37,6 +37,7 @@ type Config struct {
StatsOutputFile string `json:"stats_output_file"` // Where to store the final aggregate statistics file (in CSV format).
NoTrapInterrupts bool `json:"no_trap_interrupts"` // Should we avoid trapping Ctrl+Break? Only relevant for standalone execution mode.
SendTxPrivateKey string `json:"send_tx_private_key"` // Send tx to the chain with the private key.
WebStaticDir string `json:"web_static_dir"`
}
var validBroadcastTxMethods = map[string]interface{}{
......
......@@ -312,6 +312,7 @@ func (web *WebServicer) WebService(config Config) error {
r.HandleFunc("/tree/{uuid}", web.GetTreeHandler)
r.HandleFunc("/txslist/{hash}", web.GetTxsList)
r.HandleFunc("/txs", web.TxsHandler).Methods("POST")
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(config.WebStaticDir))))
clientFactory, exists := clientFactories["ethclient"]
if !exists {
......@@ -395,7 +396,7 @@ func FloatRound(f float64, n int) float64 {
type TxParams struct {
From string `json:"from,omitempty"`
RequestAmount int64 `json:"request_amount"`
//RequestAmount int64 `json:"request_amount"`
ToAddrs []string `json:"to_addrs"`
BatchTxSize int64 `json:"batch_tx_size,omitempty"`
BatchTxHashSize int64 `json:"batch_tx_hash_size,omitempty"`
......@@ -426,7 +427,7 @@ func (web *WebServicer) TxsHandler(w http.ResponseWriter, r *http.Request) {
atomic.StoreInt32(&Running, 1)
if params.EveryTxAmount*params.TxCount < params.RequestAmount && params.RequestAmount > MaxRequestAmount {
if params.EveryTxAmount*params.TxCount < MaxRequestAmount {
http.Error(w, fmt.Sprintf("params.EveryTxAmount*params.TxCount < params.RequestAmount && params.RequestAmount > %d", MaxRequestAmount), http.StatusBadRequest)
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment