From 1dfc133c0167fbba818b46883950bf87554f5dc1 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 17 Jun 2019 02:14:13 -0400 Subject: add unknown peer callback --- test_p2p_stress/main.go | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'test_p2p_stress') diff --git a/test_p2p_stress/main.go b/test_p2p_stress/main.go index d6f3b71..251f2e1 100644 --- a/test_p2p_stress/main.go +++ b/test_p2p_stress/main.go @@ -87,17 +87,6 @@ type TestContext struct { ncompleted int } -func (self TestContext) Free() { - if self.timer != nil { - C.free(unsafe.Pointer(self.timer_ctx)) - } -} - -func (self AppContext) Free() { - for _, tc:= range self.tc { - tc.Free() - } -} type AppContext struct { addr salticidae.NetAddr @@ -107,6 +96,14 @@ type AppContext struct { tc map[uint64] *TestContext } +func (self AppContext) Free() { + for _, tc := range self.tc { + if tc.timer != nil { + C.free(unsafe.Pointer(tc.timer_ctx)) + } + } +} + func NewTestContext() TestContext { return TestContext { ncompleted: 0 } } @@ -157,11 +154,9 @@ func onTimeout(_ *C.timerev_t, userdata unsafe.Pointer) { //export onReceiveRand func onReceiveRand(_msg *C.struct_msg_t, _conn *C.struct_msgnetwork_conn_t, userdata unsafe.Pointer) { msg := salticidae.MsgFromC(salticidae.CMsg(_msg)) - bytes := msgRandUnserialize(msg) - hash := bytes.GetHash() conn := salticidae.MsgNetworkConnFromC(salticidae.CMsgNetworkConn(_conn)) net := conn.GetNet() - ack := msgAckSerialize(hash) + ack := msgAckSerialize(msgRandUnserialize(msg).GetHash()) net.SendMsgByMove(ack, conn) } @@ -175,7 +170,6 @@ func onReceiveAck(_msg *C.struct_msg_t, _conn *C.struct_msgnetwork_conn_t, userd tc := app.getTC(addr) if !hash.IsEq(tc.hash) { - //fmt.Printf("%s %s\n", hash.GetHex(), tc.hash.GetHex()) panic("corrupted I/O!") } -- cgit v1.2.3-70-g09d2