本文整理汇总了C#中BitcoinStream.ReadWriteAsVarString方法的典型用法代码示例。如果您正苦于以下问题:C# BitcoinStream.ReadWriteAsVarString方法的具体用法?C# BitcoinStream.ReadWriteAsVarString怎么用?C# BitcoinStream.ReadWriteAsVarString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitcoinStream
的用法示例。
在下文中一共展示了BitcoinStream.ReadWriteAsVarString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadScript
private bool ReadScript(Script script)
{
try
{
var data = TxNullDataTemplate.Instance.ExtractScriptPubKeyParameters(script);
if(data == null)
return false;
BitcoinStream stream = new BitcoinStream(data);
ushort marker = 0;
stream.ReadWrite(ref marker);
if(marker != Tag)
return false;
stream.ReadWrite(ref _Version);
if(_Version != 1)
return false;
ulong quantityCount = 0;
stream.ReadWriteAsVarInt(ref quantityCount);
Quantities = new ulong[quantityCount];
for(ulong i = 0 ; i < quantityCount ; i++)
{
Quantities[i] = ReadLEB128(stream);
if(Quantities[i] > MAX_QUANTITY)
return false;
}
stream.ReadWriteAsVarString(ref _Metadata);
return true;
}
catch(Exception)
{
return false;
}
}
示例2: ReadData
private bool ReadData(byte[] data)
{
try
{
BitcoinStream stream = new BitcoinStream(data);
ushort marker = 0;
stream.ReadWrite(ref marker);
if(marker != Tag)
return false;
stream.ReadWrite(ref _Version);
if(_Version != 1)
return false;
ulong quantityCount = 0;
stream.ReadWriteAsVarInt(ref quantityCount);
Quantities = new ulong[quantityCount];
for(ulong i = 0 ; i < quantityCount ; i++)
{
Quantities[i] = ReadLEB128(stream);
if(Quantities[i] > MAX_QUANTITY)
return false;
}
stream.ReadWriteAsVarString(ref _Metadata);
if(stream.Inner.Position != data.Length)
return false;
return true;
}
catch(Exception)
{
return false;
}
}
示例3: ReadWrite
// serialization implementation
#region IBitcoinSerializable Members
public void ReadWrite(BitcoinStream stream)
{
stream.ReadWrite(ref _TransactionCount);
stream.ReadWrite(ref _Hashes);
byte[] vBytes = null;
if(!stream.Serializing)
{
stream.ReadWriteAsVarString(ref vBytes);
BitWriter writer = new BitWriter();
for(int p = 0 ; p < vBytes.Length * 8 ; p++)
writer.Write((vBytes[p / 8] & (1 << (p % 8))) != 0);
_Flags = writer.ToBitArray();
}
else
{
vBytes = new byte[(_Flags.Length + 7) / 8];
for(int p = 0 ; p < _Flags.Length ; p++)
vBytes[p / 8] |= (byte)(ToByte(_Flags.Get(p)) << (p % 8));
stream.ReadWriteAsVarString(ref vBytes);
}
}
示例4: ReadWriteCore
public override void ReadWriteCore(BitcoinStream stream)
{
stream.ReadWriteAsVarString(ref _Data);
}
示例5: ToBytes
public byte[] ToBytes()
{
MemoryStream ms = new MemoryStream();
BitcoinStream stream = new BitcoinStream(ms, true);
stream.ReadWrite(Tag);
stream.ReadWrite(ref _Version);
var quantityCount = (uint)this.Quantities.Length;
stream.ReadWriteAsVarInt(ref quantityCount);
for(int i = 0 ; i < quantityCount ; i++)
{
if(Quantities[i] > MAX_QUANTITY)
throw new ArgumentOutOfRangeException("Quantity should not exceed " + Quantities[i]);
WriteLEB128(Quantities[i], stream);
}
stream.ReadWriteAsVarString(ref _Metadata);
return ms.ToArray();
}
示例6: ReadWrite
public void ReadWrite(BitcoinStream stream)
{
stream.ReadWriteAsVarString(ref _Data);
}
示例7: ReadWrite
public void ReadWrite(BitcoinStream stream)
{
stream.ReadWrite(ref nTransactions);
stream.ReadWrite(ref vHash);
byte[] vBytes = null;
if(!stream.Serializing)
{
stream.ReadWriteAsVarString(ref vBytes);
PartialMerkleTree us = this; //Might need copy
us.vBits = us.vBits.Take(vBytes.Length * 8).ToList();
for(int p = 0 ; p < us.vBits.Count ; p++)
us.vBits[p] = (vBytes[p / 8] & (1 << (p % 8))) != 0;
us.fBad = false;
}
else
{
vBytes = new byte[(vBits.Count + 7) / 8];
for(int p = 0 ; p < vBits.Count ; p++)
vBytes[p / 8] |= (byte)(ToByte(vBits[p]) << (p % 8));
stream.ReadWriteAsVarString(ref vBytes);
}
}
示例8: ReadWrite
public void ReadWrite(BitcoinStream stream)
{
stream.ReadWriteAsVarString(ref vData);
stream.ReadWrite(ref nHashFuncs);
stream.ReadWrite(ref nTweak);
stream.ReadWrite(ref nFlags);
}
示例9: ReadWrite
public void ReadWrite(BitcoinStream stream)
{
var b = _Block == null ? new uint256(0).ToBytes() : _Block.ToBytes();
stream.ReadWrite(ref b);
if(!stream.Serializing)
_Block = new uint256(b) == 0 ? null : new uint256(b);
stream.ReadWrite(ref _Reason);
stream.ReadWrite(ref _Spendable);
var change = BalanceChange.Satoshi.ToByteArray();
stream.ReadWriteAsVarString(ref change);
if(!stream.Serializing)
_BalanceChange = new Money(new BigInteger(change));
}
示例10: GetScript
public Script GetScript()
{
MemoryStream ms = new MemoryStream();
BitcoinStream stream = new BitcoinStream(ms, true);
stream.ReadWrite(Tag);
stream.ReadWrite(ref _Version);
var quantityCount = (uint)this.Quantities.Length;
stream.ReadWriteAsVarInt(ref quantityCount);
for(int i = 0 ; i < quantityCount ; i++)
{
if(Quantities[i] > MAX_QUANTITY)
throw new ArgumentOutOfRangeException("Quantity should not exceed " + Quantities[i]);
WriteLEB128(Quantities[i], stream);
}
stream.ReadWriteAsVarString(ref _Metadata);
return TxNullDataTemplate.Instance.GenerateScriptPubKey(ms.ToArray());
}