Esempio n. 1
0
        public static byte[] WithHeader(byte[] message)
        {
            int i = BinaryHelpers.VarIntSize(message.Length);

            byte[] nmsg = new byte[message.Length + i];
            //Support.WriteToArray(nmsg, message.Length, 0);
            BinaryHelpers.WriteVarInt(nmsg, 0, message.Length);
            Array.Copy(message, 0, nmsg, i, message.Length);
            Debug.WriteLine($"Compression:  {nmsg.Length}/{Compress(nmsg, Compression.int16).Length}/{Compress(nmsg, Compression.int32).Length}/{Compress(nmsg, Compression.int64).Length}");
            Debug.WriteLine($"Matches: {Support.ArraysEqual(nmsg, Decompress(Compress(nmsg)))}");
            return(nmsg);
        }