当前位置: 首页>>代码示例>>C#>>正文


C# BitcoinStream.ReadWriteAsVarString方法代码示例

本文整理汇总了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;
			}
		}
开发者ID:xcrash,项目名称:NBitcoin,代码行数:35,代码来源:ColorMarker.cs

示例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;
			}
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:34,代码来源:ColorMarker.cs

示例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);
			}
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:24,代码来源:PartialMerkleTree.cs

示例4: ReadWriteCore

		public override void ReadWriteCore(BitcoinStream stream)
		{
			stream.ReadWriteAsVarString(ref _Data);
		}
开发者ID:crowar,项目名称:NBitcoin,代码行数:4,代码来源:FilterAddPayload.cs

示例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();
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:17,代码来源:ColorMarker.cs

示例6: ReadWrite

 public void ReadWrite(BitcoinStream stream)
 {
     stream.ReadWriteAsVarString(ref _Data);
 }
开发者ID:nikropht,项目名称:NBitcoin,代码行数:4,代码来源:RepositoryTests.cs

示例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);
            }
        }
开发者ID:nikropht,项目名称:NBitcoin,代码行数:23,代码来源:PartialMerkleTree.cs

示例8: ReadWrite

		public void ReadWrite(BitcoinStream stream)
		{
			stream.ReadWriteAsVarString(ref vData);
			stream.ReadWrite(ref nHashFuncs);
			stream.ReadWrite(ref nTweak);
			stream.ReadWrite(ref nFlags);
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:7,代码来源:BloomFilter.cs

示例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));
        }
开发者ID:royosherove,项目名称:NBitcoin,代码行数:14,代码来源:Account.cs

示例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());
		}
开发者ID:xcrash,项目名称:NBitcoin,代码行数:17,代码来源:ColorMarker.cs


注:本文中的BitcoinStream.ReadWriteAsVarString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。