diff options
author | Determinant <[email protected]> | 2019-06-30 18:35:20 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-06-30 18:35:20 -0400 |
commit | bbe214128b6f7cb4e57fcda7adc3205ec9ec66cb (patch) | |
tree | 67563de5f0ab2bd9cef29e5ed7efb25398f6219c /test_p2p_stress | |
parent | d247c437f396709f62eadaf863b8a552d7142fc7 (diff) |
allow manual memory management for types frequently used in messaging
Diffstat (limited to 'test_p2p_stress')
-rw-r--r-- | test_p2p_stress/main.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test_p2p_stress/main.go b/test_p2p_stress/main.go index b358d5d..29cfbfa 100644 --- a/test_p2p_stress/main.go +++ b/test_p2p_stress/main.go @@ -42,7 +42,7 @@ const ( ) func msgRandSerialize(view uint32, size int) (salticidae.Msg, salticidae.UInt256) { - serialized := salticidae.NewDataStream() + serialized := salticidae.NewDataStream(true) serialized.PutU32(salticidae.ToLittleEndianU32(view)) buffer := make([]byte, size) _, err := rand.Read(buffer) @@ -50,32 +50,32 @@ func msgRandSerialize(view uint32, size int) (salticidae.Msg, salticidae.UInt256 panic("rand source failed") } serialized.PutData(buffer) - hash := salticidae.NewByteArrayFromBytes(buffer).GetHash() + hash := salticidae.NewByteArrayFromBytes(buffer, true).GetHash(true) return salticidae.NewMsgMovedFromByteArray( MSG_OPCODE_RAND, - salticidae.NewByteArrayMovedFromDataStream(serialized)), hash + salticidae.NewByteArrayMovedFromDataStream(serialized, true), true), hash } func msgRandUnserialize(msg salticidae.Msg) (view uint32, hash salticidae.UInt256) { d := msg.GetPayloadByMove() succ := true view = salticidae.FromLittleEndianU32(d.GetU32(&succ)) - hash = salticidae.NewByteArrayCopiedFromDataStream(d).GetHash() + hash = salticidae.NewByteArrayCopiedFromDataStream(d, true).GetHash(true) return } func msgAckSerialize(view uint32, hash salticidae.UInt256) salticidae.Msg { - serialized := salticidae.NewDataStream() + serialized := salticidae.NewDataStream(true) serialized.PutU32(salticidae.ToLittleEndianU32(view)) hash.Serialize(serialized) return salticidae.NewMsgMovedFromByteArray( MSG_OPCODE_ACK, - salticidae.NewByteArrayMovedFromDataStream(serialized)) + salticidae.NewByteArrayMovedFromDataStream(serialized, true), true) } func msgAckUnserialize(msg salticidae.Msg) (view uint32, hash salticidae.UInt256) { p := msg.GetPayloadByMove() - hash = salticidae.NewUInt256() + hash = salticidae.NewUInt256(true) succ := true view = salticidae.FromLittleEndianU32(p.GetU32(&succ)) hash.Unserialize(p) |