本文整理汇总了C#中BitcoinStream.ReadWriteAsCompactVarInt方法的典型用法代码示例。如果您正苦于以下问题:C# BitcoinStream.ReadWriteAsCompactVarInt方法的具体用法?C# BitcoinStream.ReadWriteAsCompactVarInt怎么用?C# BitcoinStream.ReadWriteAsCompactVarInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitcoinStream
的用法示例。
在下文中一共展示了BitcoinStream.ReadWriteAsCompactVarInt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadWrite
public void ReadWrite(BitcoinStream stream)
{
if(stream.Serializing)
{
uint o = (uint)(nHeight * 2 + (fCoinBase ? 1 : 0));
stream.ReadWriteAsCompactVarInt(ref o);
if(nHeight > 0)
stream.ReadWriteAsCompactVarInt(ref nVersion);
TxOutCompressor compressor = new TxOutCompressor(txout);
stream.ReadWrite(ref compressor);
}
else
{
uint nCode = 0;
stream.ReadWriteAsCompactVarInt(ref nCode);
nHeight = nCode / 2;
fCoinBase = (nCode & 1) != 0;
if(nHeight > 0)
stream.ReadWriteAsCompactVarInt(ref nVersion);
TxOutCompressor compressor = new TxOutCompressor();
stream.ReadWrite(ref compressor);
txout = compressor.TxOut;
}
}
示例2: ReadWrite
public void ReadWrite(BitcoinStream stream)
{
if(stream.Serializing)
{
var compr = Compress();
if(compr != null)
{
stream.ReadWrite(ref compr);
return;
}
uint nSize = (uint)_Script.Length + nSpecialScripts;
stream.ReadWriteAsCompactVarInt(ref nSize);
stream.ReadWrite(ref _Script);
}
else
{
uint nSize = 0;
stream.ReadWriteAsCompactVarInt(ref nSize);
if(nSize < nSpecialScripts)
{
byte[] vch = new byte[GetSpecialSize(nSize)];
stream.ReadWrite(ref vch);
_Script = Decompress(nSize, vch).ToRawScript();
return;
}
nSize -= nSpecialScripts;
_Script = new byte[nSize];
stream.ReadWrite(ref _Script);
}
}
示例3: ReadWrite
public void ReadWrite(BitcoinStream stream)
{
stream.ReadWrite(ref _Add);
stream.ReadWriteAsCompactVarInt(ref _HeightOrBackstep);
if(_Add)
{
stream.ReadWrite(ref _BlockHeader);
}
}