Example #1
0
 public MessageHeader(CurrencyNet currencyNet, MsgCommand command, byte[] payload)
 {
     CurrencyNetwork = currencyNet;
     Command         = command;
     PayloadLength   = payload.Length;
     Checksum        = HashUtil.Blake256(payload).Take(ChecksumLengthBytes).ToArray();
 }
Example #2
0
        public override void Decode(BinaryReader reader)
        {
            CurrencyNetwork = (CurrencyNet)reader.ReadUInt32();

            Command = new MsgCommand();
            Command.Decode(reader);

            PayloadLength = reader.ReadInt32();
            Checksum      = reader.ReadBytes(ChecksumLengthBytes);
        }
Example #3
0
        public override void Decode(BinaryReader reader)
        {
            RejectedCommand = reader.ReadVariableLengthString(MaxMessagePayload);
            Code            = (RejectCode)reader.ReadByte();
            Reason          = reader.ReadVariableLengthString(MaxMessagePayload);

            var msgCommand = MsgCommand.Find(RejectedCommand);

            if (msgCommand == MsgCommand.Block || msgCommand == MsgCommand.Tx)
            {
                Hash = reader.ReadBytes(32);
            }
        }
Example #4
0
        public override void Encode(BinaryWriter writer)
        {
            writer.WriteVariableLengthString(RejectedCommand);
            writer.Write((byte)Code);
            writer.WriteVariableLengthString(Reason);

            var msgCommand = MsgCommand.Find(RejectedCommand);

            if (msgCommand == MsgCommand.Block || msgCommand == MsgCommand.Tx)
            {
                writer.Write(Hash);
            }
        }
Example #5
0
 protected bool Equals(MsgCommand other)
 {
     return(string.Equals(Name, other.Name));
 }