diff options
author | Determinant <[email protected]> | 2019-06-14 17:49:28 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-06-14 17:49:28 -0400 |
commit | cb133a379998112600ea1504b556484a417cf48a (patch) | |
tree | bbdc377f6e49f593ff42d5755ddd95c9f288f5f3 /test_p2p_stress | |
parent | 6e9c400985c3e553509d926f1d31094fbd344c8f (diff) |
update the library; fix bugs
Diffstat (limited to 'test_p2p_stress')
-rw-r--r-- | test_p2p_stress/main.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test_p2p_stress/main.go b/test_p2p_stress/main.go index 1051440..6670f03 100644 --- a/test_p2p_stress/main.go +++ b/test_p2p_stress/main.go @@ -26,6 +26,7 @@ import "C" import ( "github.com/Determinant/salticidae-go" "math/rand" + "os" "fmt" "sync" "unsafe" @@ -70,6 +71,13 @@ func msgAckUnserialize(msg salticidae.Msg) salticidae.UInt256 { return hash } +func checkError(err *salticidae.Error) { + if err.GetCode() != 0 { + fmt.Printf("error during a sync call: %s\n", salticidae.StrError(err.GetCode())) + os.Exit(1) + } +} + type TestContext struct { timer salticidae.TimerEvent timer_ctx *C.struct_timeout_callback_context_t @@ -133,8 +141,7 @@ func sendRand(size int, app *AppContext, conn salticidae.MsgNetworkConn) { salticidae.UInt256(tc.hash).Free() } tc.hash = hash - app.net.AsMsgNetwork().SendMsg(msg, conn) - msg.Free() + app.net.AsMsgNetwork().SendMsgByMove(msg, conn) } var apps []AppContext @@ -165,9 +172,8 @@ func onReceiveRand(_msg *C.struct_msg_t, _conn *C.struct_msgnetwork_conn_t, user conn := salticidae.MsgNetworkConn(_conn) net := conn.GetNet() ack := msgAckSerialize(hash) - net.SendMsg(ack, conn) hash.Free() - ack.Free() + net.SendMsgByMove(ack, conn) } //export onReceiveAck @@ -287,8 +293,9 @@ func main() { for i, _ := range apps { app_id := i go func() { + err := salticidae.NewError() a := &apps[app_id] - a.net.Listen(a.addr) + a.net.Listen(a.addr, &err) for _, addr := range addrs { if !addr.IsEq(a.addr) { a.net.AddPeer(addr) |