From cb133a379998112600ea1504b556484a417cf48a Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 14 Jun 2019 17:49:28 -0400 Subject: update the library; fix bugs --- test_p2p_stress/main.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'test_p2p_stress') 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) -- cgit v1.2.3-70-g09d2