2015-12-07 17:54:19 -08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-07-31 18:44:46 -04:00
|
|
|
"context"
|
2015-12-09 09:37:36 -08:00
|
|
|
"encoding/binary"
|
2015-12-07 17:54:19 -08:00
|
|
|
"fmt"
|
2017-10-04 16:40:45 -04:00
|
|
|
"time"
|
2015-12-07 17:54:19 -08:00
|
|
|
|
2018-07-01 22:36:49 -04:00
|
|
|
cmn "github.com/tendermint/tendermint/libs/common"
|
2018-08-10 00:25:57 -05:00
|
|
|
rpcclient "github.com/tendermint/tendermint/rpc/lib/client"
|
2015-12-07 17:54:19 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-06-12 02:25:52 -07:00
|
|
|
wsc := rpcclient.NewWSClient("127.0.0.1:26657", "/websocket")
|
2017-11-06 13:20:39 -05:00
|
|
|
err := wsc.Start()
|
2015-12-07 17:54:19 -08:00
|
|
|
if err != nil {
|
2017-07-31 18:44:46 -04:00
|
|
|
cmn.Exit(err.Error())
|
2015-12-07 17:54:19 -08:00
|
|
|
}
|
2017-07-31 18:44:46 -04:00
|
|
|
defer wsc.Stop()
|
2015-12-07 17:54:19 -08:00
|
|
|
|
|
|
|
// Read a bunch of responses
|
|
|
|
go func() {
|
|
|
|
for {
|
2017-10-24 17:38:12 +01:00
|
|
|
_, ok := <-wsc.ResponsesCh
|
2015-12-07 17:54:19 -08:00
|
|
|
if !ok {
|
|
|
|
break
|
|
|
|
}
|
2015-12-08 08:11:29 -08:00
|
|
|
//fmt.Println("Received response", string(wire.JSONBytes(res)))
|
2015-12-07 17:54:19 -08:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// Make a bunch of requests
|
2015-12-09 09:37:36 -08:00
|
|
|
buf := make([]byte, 32)
|
2015-12-07 17:54:19 -08:00
|
|
|
for i := 0; ; i++ {
|
2016-01-25 14:34:08 -08:00
|
|
|
binary.BigEndian.PutUint64(buf, uint64(i))
|
2015-12-09 09:37:36 -08:00
|
|
|
//txBytes := hex.EncodeToString(buf[:n])
|
2015-12-09 13:53:31 -08:00
|
|
|
fmt.Print(".")
|
2017-07-31 18:44:46 -04:00
|
|
|
err = wsc.Call(context.TODO(), "broadcast_tx", map[string]interface{}{"tx": buf[:8]})
|
2015-12-07 17:54:19 -08:00
|
|
|
if err != nil {
|
2017-07-31 18:44:46 -04:00
|
|
|
cmn.Exit(err.Error())
|
2015-12-07 17:54:19 -08:00
|
|
|
}
|
2015-12-09 13:53:31 -08:00
|
|
|
if i%1000 == 0 {
|
2015-12-08 08:11:29 -08:00
|
|
|
fmt.Println(i)
|
|
|
|
}
|
2016-01-02 16:23:29 -08:00
|
|
|
time.Sleep(time.Microsecond * 1000)
|
2015-12-07 17:54:19 -08:00
|
|
|
}
|
|
|
|
}
|