當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。