本文整理汇总了C#中BitcoinStream.CopyParameters方法的典型用法代码示例。如果您正苦于以下问题:C# BitcoinStream.CopyParameters方法的具体用法?C# BitcoinStream.CopyParameters怎么用?C# BitcoinStream.CopyParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitcoinStream
的用法示例。
在下文中一共展示了BitcoinStream.CopyParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadWrite
public void ReadWrite(BitcoinStream stream)
{
if(Payload == null && stream.Serializing)
throw new InvalidOperationException("Payload not affected");
if(stream.Serializing || (!stream.Serializing && !_SkipMagic))
stream.ReadWrite(ref magic);
stream.ReadWrite(ref command);
int length = 0;
uint checksum = 0;
bool hasChecksum = false;
byte[] payloadBytes = stream.Serializing ? GetPayloadBytes(stream.ProtocolVersion, out length) : null;
length = payloadBytes == null ? 0 : length;
stream.ReadWrite(ref length);
if(stream.ProtocolVersion >= ProtocolVersion.MEMPOOL_GD_VERSION)
{
if(stream.Serializing)
checksum = Hashes.Hash256(payloadBytes, 0, length).GetLow32();
stream.ReadWrite(ref checksum);
hasChecksum = true;
}
if(stream.Serializing)
{
stream.ReadWrite(ref payloadBytes, 0, length);
}
else
{
if(length > 0x02000000) //MAX_SIZE 0x02000000 Serialize.h
{
throw new FormatException("Message payload too big ( > 0x02000000 bytes)");
}
payloadBytes = _Buffer == null || _Buffer.Length < length ? new byte[length] : _Buffer;
stream.ReadWrite(ref payloadBytes, 0, length);
if(hasChecksum)
{
if(!VerifyChecksum(checksum, payloadBytes, length))
{
if(NodeServerTrace.Trace.Switch.ShouldTrace(TraceEventType.Verbose))
NodeServerTrace.Trace.TraceEvent(TraceEventType.Verbose, 0, "Invalid message checksum bytes");
throw new FormatException("Message checksum invalid");
}
}
BitcoinStream payloadStream = new BitcoinStream(payloadBytes);
payloadStream.CopyParameters(stream);
var payloadType = PayloadAttribute.GetCommandType(Command);
var unknown = payloadType == typeof(UnknowPayload);
if(unknown)
NodeServerTrace.Trace.TraceEvent(TraceEventType.Warning, 0, "Unknown command received : " + Command);
object payload = _PayloadObject;
payloadStream.ReadWrite(payloadType, ref payload);
if(unknown)
((UnknowPayload)payload)._Command = Command;
Payload = (Payload)payload;
}
}
示例2: UpdatePayload
private void UpdatePayload(BitcoinStream stream)
{
MemoryStream ms = new MemoryStream();
var seria = new BitcoinStream(ms, true);
seria.CopyParameters(stream);
ReadWritePayloadFields(seria);
payload = new VarString(ms.ToArray());
}
示例3: ReadWriteCore
public override void ReadWriteCore(BitcoinStream stream)
{
stream.ReadWrite(ref payload);
if(!stream.Serializing)
{
var payloadStream = new BitcoinStream(payload.GetString());
payloadStream.CopyParameters(stream);
ReadWritePayloadFields(payloadStream);
}
stream.ReadWrite(ref signature);
}
示例4: ReadWrite
public void ReadWrite(BitcoinStream stream)
{
bool verifyChechksum = false;
if(stream.Serializing || (!stream.Serializing && !_SkipMagic))
stream.ReadWrite(ref magic);
stream.ReadWrite(ref command);
stream.ReadWrite(ref length);
if(stream.ProtocolVersion >= ProtocolVersion.MEMPOOL_GD_VERSION)
{
stream.ReadWrite(ref checksum);
verifyChechksum = true;
}
if(stream.Serializing)
{
stream.ReadWrite(ref payload);
}
else
{
NodeServerTrace.Trace.TraceEvent(TraceEventType.Verbose, 0, "Message type readen : " + Command);
if(length > 0x02000000) //MAX_SIZE 0x02000000 Serialize.h
{
throw new FormatException("Message payload too big ( > 0x02000000 bytes)");
}
payload = new byte[length];
stream.ReadWrite(ref payload);
if(verifyChechksum)
{
if(!VerifyChecksum())
{
NodeServerTrace.Trace.TraceEvent(TraceEventType.Verbose, 0, "Invalid message checksum bytes : "
+ Encoders.Hex.EncodeData(this.ToBytes()));
throw new FormatException("Message checksum invalid");
}
}
BitcoinStream payloadStream = new BitcoinStream(payload);
payloadStream.CopyParameters(stream);
var payloadType = PayloadAttribute.GetCommandType(Command);
if(payloadType == typeof(UnknowPayload))
NodeServerTrace.Trace.TraceEvent(TraceEventType.Warning, 0, "Unknown command received : " + Command);
payloadStream.ReadWrite(payloadType, ref _PayloadObject);
}
}