Exemplo n.º 1
0
 public MessageHeader(CurrencyNet currencyNet, MsgCommand command, byte[] payload)
 {
     CurrencyNetwork = currencyNet;
     Command         = command;
     PayloadLength   = payload.Length;
     Checksum        = HashUtil.Blake256(payload).Take(ChecksumLengthBytes).ToArray();
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 5
0
 protected bool Equals(MsgCommand other)
 {
     return(string.Equals(Name, other.Name));
 }