public MessageHeader(CurrencyNet currencyNet, MsgCommand command, byte[] payload) { CurrencyNetwork = currencyNet; Command = command; PayloadLength = payload.Length; Checksum = HashUtil.Blake256(payload).Take(ChecksumLengthBytes).ToArray(); }
public override void Decode(BinaryReader reader) { CurrencyNetwork = (CurrencyNet)reader.ReadUInt32(); Command = new MsgCommand(); Command.Decode(reader); PayloadLength = reader.ReadInt32(); Checksum = reader.ReadBytes(ChecksumLengthBytes); }
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); } }
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); } }
protected bool Equals(MsgCommand other) { return(string.Equals(Name, other.Name)); }