diff options
author | Determinant <[email protected]> | 2019-06-17 02:14:13 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-06-17 02:14:13 -0400 |
commit | 1dfc133c0167fbba818b46883950bf87554f5dc1 (patch) | |
tree | 91d4244e8cd9768f4448588b45cd09e48331c73e /test_p2p_stress | |
parent | 8ac5ed4cf4518053c81122c01cd4a665aca0a549 (diff) |
add unknown peer callback
Diffstat (limited to 'test_p2p_stress')
-rw-r--r-- | test_p2p_stress/main.go | 24 |
1 files changed, 9 insertions, 15 deletions
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!") } |