• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# uint256类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中uint256的典型用法代码示例。如果您正苦于以下问题:C# uint256类的具体用法?C# uint256怎么用?C# uint256使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



uint256类属于命名空间,在下文中一共展示了uint256类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Entity

 public Entity(uint256 txId)
 {
     if(txId == null)
         throw new ArgumentNullException("txId");
     Timestamp = DateTimeOffset.UtcNow;
     TxId = txId;
 }
开发者ID:bijakatlykkex,项目名称:NBitcoin.Indexer,代码行数:7,代码来源:TransactionEntry.cs


示例2: GetTransactionAsync

		/// <summary>
		/// Gets a transaction.
		/// </summary>
		/// <param name="txId">The transaction identifier.</param>
		/// <returns>Given a transaction hash (id) returns the requested transaction object.</returns>
		/// <exception cref="System.ArgumentNullException">txId cannot be null</exception>
		public async Task<Transaction> GetTransactionAsync(uint256 txId)
		{
			if (txId == null) throw new ArgumentNullException("txId");

			var result = await SendRequestAsync("tx", _format, txId.ToString());
			return new Transaction(result); 
		}
开发者ID:xcrash,项目名称:NBitcoin,代码行数:13,代码来源:RestClient.cs


示例3: uint256_tests

		public uint256_tests()
		{
			R1Array = ToBytes("\x9c\x52\x4a\xdb\xcf\x56\x11\x12\x2b\x29\x12\x5e\x5d\x35\xd2\xd2\x22\x81\xaa\xb5\x33\xf0\x08\x32\xd5\x56\xb1\xf9\xea\xe5\x1d\x7d");
			R1L = new uint256(R1Array);
			NegR1L = ~R1L;
			R1S = new uint160(R1Array.Take(20).ToArray());
			NegR1S = ~R1S;
			NegR1Array = NegR1L.ToBytes();

			R2Array = ToBytes("\x70\x32\x1d\x7c\x47\xa5\x6b\x40\x26\x7e\x0a\xc3\xa6\x9c\xb6\xbf\x13\x30\x47\xa3\x19\x2d\xda\x71\x49\x13\x72\xf0\xb4\xca\x81\xd7");
			R2L = new uint256(R2Array);
			NegR2L = ~R2L;
			R2S = new uint160(R2Array.Take(20).ToArray());
			NegR2S = ~R2S;
			NegR2Array = NegR2L.ToBytes();

			ZeroArray = ToBytes("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00");
			ZeroL = new uint256(ZeroArray);
			ZeroS = new uint160(ZeroArray.Take(20).ToArray());

			OneArray = ToBytes("\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00");
			OneL = new uint256(OneArray);
			OneS = new uint160(OneArray.Take(20).ToArray());

			MaxArray = ToBytes("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
			MaxL = new uint256(MaxArray);
			MaxS = new uint160(MaxArray.Take(20).ToArray());

			HalfL = OneL << 255;
			HalfS = OneS << 159;
		}
开发者ID:xcrash,项目名称:NBitcoin,代码行数:31,代码来源:uint256_tests.cs


示例4: GetBlockAsync

		/// <summary>
		/// Gets the block.
		/// </summary>
		/// <param name="blockId">The block identifier.</param>
		/// <returns>Given a block hash (id) returns the requested block object.</returns>
		/// <exception cref="System.ArgumentNullException">blockId cannot be null.</exception>
		public async Task<Block> GetBlockAsync(uint256 blockId)
		{
			if (blockId == null) throw new ArgumentNullException("blockId");

			var result = await SendRequestAsync("block", _format, blockId.ToString()).ConfigureAwait(false); ;
			return new Block(result);
		}
开发者ID:xcrash,项目名称:NBitcoin,代码行数:13,代码来源:RestClient.cs


示例5: GetId

			public static string GetId(uint256 txId, uint256 blockId, int height)
			{
				return string.Format("{0}-{1}-{2}", 
					(blockId == null ? (int.MaxValue - 1) : height),
					(blockId ?? uint256.Zero),
					txId);
			}
开发者ID:xcrash,项目名称:NBitcoin,代码行数:7,代码来源:Tracker.cs


示例6: PutAsync

 public async Task PutAsync(uint256 txId, Transaction tx)
 {
     foreach(var repo in _Repositories)
     {
         await repo.PutAsync(txId, tx).ConfigureAwait(false);
     }
 }
开发者ID:bijakatlykkex,项目名称:NBitcoin.Indexer,代码行数:7,代码来源:IndexerColoredTransactionRepository.cs


示例7: GetAsync

 public async Task<Transaction> GetAsync(uint256 txId)
 {
     var tx = await _Configuration.CreateIndexerClient().GetTransactionAsync(false, txId).ConfigureAwait(false);
     if (tx == null)
         return null;
     return tx.Transaction;
 }
开发者ID:bijakatlykkex,项目名称:NBitcoin.Indexer,代码行数:7,代码来源:IndexerTransactionRepository.cs


示例8: GetFromCache

		public ColoredTransaction GetFromCache(uint256 txId)
		{
			using(_lock.LockRead())
			{
				return _ColoredTransactions.TryGet(txId);
			}
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:7,代码来源:CachedColoredTransactionRepository.cs


示例9: Sign

		public ECDSASignature Sign(uint256 hash)
		{
			AssertPrivateKey();
			var signer = new DeterministicECDSA();
			signer.setPrivateKey(PrivateKey);
			var sig = ECDSASignature.FromDER(signer.signHash(hash.ToBytes()));
			return sig.MakeCanonical();
		}
开发者ID:crowar,项目名称:NBitcoin,代码行数:8,代码来源:ECKey.cs


示例10: GetAsync

 public async Task<Transaction> GetAsync(uint256 txId)
 {
     foreach(var repo in _Repositories)
     {
         var result = await repo.GetAsync(txId).ConfigureAwait(false);
         if(result != null)
             return result;
     }
     return null;
 }
开发者ID:bijakatlykkex,项目名称:NBitcoin.Indexer,代码行数:10,代码来源:IndexerColoredTransactionRepository.cs


示例11: PutAsync

		public Task PutAsync(uint256 txId, ColoredTransaction tx)
		{
			using(_lock.LockWrite())
			{
				if(!_ColoredTransactions.ContainsKey(txId))
					_ColoredTransactions.AddOrReplace(txId, tx);
				else
					_ColoredTransactions[txId] = tx;
				return _Inner.PutAsync(txId, tx);
			}
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:11,代码来源:CachedColoredTransactionRepository.cs


示例12: Put

		public static void Put(this IColoredTransactionRepository repo, uint256 txId, ColoredTransaction tx)
		{
			try
			{
				repo.PutAsync(txId, tx).Wait();
			}
			catch(AggregateException aex)
			{
				ExceptionDispatchInfo.Capture(aex.InnerException).Throw();
			}
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:11,代码来源:IColoredTransactionRepository.cs


示例13: ParseCore

        internal static BalanceLocator ParseCore(string[] splitted, bool queryFormat)
        {
            if (splitted.Length < 2)
                throw InvalidUnconfirmedBalance();

            uint date = ParseUint(splitted[1]);
            uint256 transactionId = null;
            if (splitted.Length >= 3)
                transactionId = new uint256(Encoders.Hex.DecodeData(splitted[2]), false);
            return new UnconfirmedBalanceLocator(Utils.UnixTimeToDateTime(date), transactionId);
        }
开发者ID:bijakatlykkex,项目名称:NBitcoin.Indexer,代码行数:11,代码来源:BalanceQuery.cs


示例14: GetBlock

		/// <summary>
		/// Gets the block.
		/// </summary>
		/// <param name="blockId">The block identifier.</param>
		/// <returns>Given a block hash (id) returns the requested block object.</returns>
		/// <exception cref="System.ArgumentNullException">blockId cannot be null.</exception>
		public Block GetBlock(uint256 blockId)
		{
			try
			{
				return GetBlockAsync(blockId).Result;
			}
			catch(AggregateException aex)
			{
				ExceptionDispatchInfo.Capture(aex.InnerException).Throw();
				throw;
			}
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:18,代码来源:RestClient.cs


示例15: Get

		public static ColoredTransaction Get(this IColoredTransactionRepository repo, uint256 txId)
		{
			try
			{
				return repo.GetAsync(txId).Result;
			}
			catch(AggregateException aex)
			{
				ExceptionDispatchInfo.Capture(aex.InnerException).Throw();
				return null;
			}
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:12,代码来源:IColoredTransactionRepository.cs


示例16: GetCoins

		public Coins GetCoins(uint256 txId)
		{
			try
			{
				return Index.GetAsync<Coins>(txId.ToString()).Result;
			}
			catch(AggregateException aex)
			{
				ExceptionDispatchInfo.Capture(aex.InnerException).Throw();
				return null; //Can't happen
			}
		}
开发者ID:xcrash,项目名称:NBitcoin,代码行数:12,代码来源:CoinsView.cs


示例17: BlockHeader

        public BlockHeader(uint version, uint256 prev_block_hash, uint256 merkle_root_hash, uint timestamp, Target bits, uint nonce)
        {
            if(prev_block_hash == null) throw new ArgumentNullException("prev_block_hash");
            if(merkle_root_hash == null) throw new ArgumentNullException("merkle_root_hash");
            if(bits == null) throw new ArgumentNullException("bits");

            Version = version;
            PrevBlockHash = prev_block_hash;
            MerkleRootHash = merkle_root_hash;
            Timestamp = timestamp;
            Bits = bits;
            Nonce = nonce;
        }
开发者ID:lontivero,项目名称:BitcoinLite,代码行数:13,代码来源:Blockchain.cs


示例18: BigEndian

        public void BigEndian()
        {
            var big = Packer.BigEndian;
            var arr = new byte[] { 0x01, 0x02, 0x03, 0x04, 0xff };
            CollectionAssert.AreEqual(arr.Reverse(), big.GetBytes(arr));

            // booleans
            CollectionAssert.AreEqual(Hex2Bytes("01"), big.GetBytes(true));
            CollectionAssert.AreEqual(Hex2Bytes("00"), big.GetBytes(false));
            Assert.AreEqual(false, big.ToBoolean(Hex2Bytes("00"), 0));
            Assert.AreEqual(true, big.ToBoolean(Hex2Bytes("01"), 0));

            // chars
            CollectionAssert.AreEqual(Hex2Bytes("0061").Reverse(), big.GetBytes('a'));
            Assert.AreEqual('a', big.ToChar(Hex2Bytes("0061").Reverse().ToArray(), 0));

            // shorts
            CollectionAssert.AreEqual(Hex2Bytes("3039").Reverse(), big.GetBytes((ushort)12345));
            CollectionAssert.AreEqual(Hex2Bytes("3039").Reverse(), big.GetBytes((short)12345));
            CollectionAssert.AreEqual(Hex2Bytes("CFC7").Reverse(), big.GetBytes((short)-12345));
            Assert.AreEqual(12345, big.ToUInt16(Hex2Bytes("3039").Reverse().ToArray(), 0));
            Assert.AreEqual(12345, big.ToInt16(Hex2Bytes("3039").Reverse().ToArray(), 0));
            Assert.AreEqual(-12345, big.ToInt16(Hex2Bytes("CFC7").Reverse().ToArray(), 0));

            // ints
            CollectionAssert.AreEqual(Hex2Bytes("0034B59F").Reverse(), big.GetBytes((uint)3454367));
            CollectionAssert.AreEqual(Hex2Bytes("0034B59F").Reverse(), big.GetBytes(3454367));
            CollectionAssert.AreEqual(Hex2Bytes("FFCB4A61").Reverse(), big.GetBytes(-3454367));
            Assert.AreEqual(3454367, big.ToUInt32(Hex2Bytes("0034B59F").Reverse().ToArray(), 0));
            Assert.AreEqual(3454367, big.ToInt32(Hex2Bytes("0034B59F").Reverse().ToArray(), 0));
            Assert.AreEqual(-3454367, big.ToInt32(Hex2Bytes("FFCB4A61").Reverse().ToArray(), 0));

            // long
            CollectionAssert.AreEqual(Hex2Bytes("000000506DA33CD5").Reverse(), big.GetBytes((ulong)345436798165));
            CollectionAssert.AreEqual(Hex2Bytes("000000506DA33CD5").Reverse(), big.GetBytes(345436798165));
            CollectionAssert.AreEqual(Hex2Bytes("FFFFFFAF925CC32B").Reverse(), big.GetBytes(-345436798165));
            Assert.AreEqual(345436798165, big.ToUInt64(Hex2Bytes("000000506DA33CD5").Reverse().ToArray(), 0));
            Assert.AreEqual(345436798165, big.ToInt64(Hex2Bytes("000000506DA33CD5").Reverse().ToArray(), 0));
            Assert.AreEqual(-345436798165, big.ToInt64(Hex2Bytes("FFFFFFAF925CC32B").Reverse().ToArray(), 0));

            var u256 = new uint256(345436798165);
            var u256b = Hex2Bytes("000000000000000000000000000000000000000000000000000000506da33cd5");
            CollectionAssert.AreEqual(u256b.Reverse(), big.GetBytes(u256));
            Assert.AreEqual(u256, big.ToUInt256(u256b.Reverse().ToArray(), 0));

            var u160 = new uint160(345436798165);
            var u160b = Hex2Bytes("000000000000000000000000000000506da33cd5");
            CollectionAssert.AreEqual(u160b.Reverse(), big.GetBytes(u160));
            Assert.AreEqual(u160, big.ToUInt160(u160b.Reverse().ToArray(), 0));
        }
开发者ID:lontivero,项目名称:BitcoinLite,代码行数:50,代码来源:PackerTests.cs


示例19: BuildTransaction

        protected override void BuildTransaction(JObject json, Transaction tx)
        {
            var hash = new uint256((string)json.GetValue("hash"));
            tx.Version = (uint)json.GetValue("ver");
            tx.LockTime = (uint)json.GetValue("lock_time");
            var size = (uint)json.GetValue("size");

            var vin = (JArray)json.GetValue("in");
            int vinCount = (int)json.GetValue("vin_sz");
            for(int i = 0 ; i < vinCount ; i++)
            {
                var jsonIn = (JObject)vin[i];
                var txin = new NBitcoin.TxIn();
                tx.Inputs.Add(txin);
                var prevout = (JObject)jsonIn.GetValue("prev_out");

                txin.PrevOut.Hash = new uint256((string)prevout.GetValue("hash"));
                txin.PrevOut.N = (uint)prevout.GetValue("n");

                var script = (string)jsonIn.GetValue("scriptSig");
                if(script != null)
                {
                    txin.ScriptSig = new Script(script);
                }
                else
                {
                    var coinbase = (string)jsonIn.GetValue("coinbase");
                    txin.ScriptSig = new Script(Encoders.Hex.DecodeData(coinbase));
                }

                var seq = jsonIn.GetValue("sequence");
                if(seq != null)
                {
                    txin.Sequence = (uint)seq;
                }
            }

            var vout = (JArray)json.GetValue("out");
            int voutCount = (int)json.GetValue("vout_sz");
            for(int i = 0 ; i < voutCount ; i++)
            {
                var jsonOut = (JObject)vout[i];
                var txout = new NBitcoin.TxOut();
                tx.Outputs.Add(txout);

                txout.Value = Money.Parse((string)jsonOut.GetValue("value"));
                txout.ScriptPubKey = new Script((string)jsonOut.GetValue("scriptPubKey"));
            }
        }
开发者ID:nikropht,项目名称:NBitcoin,代码行数:49,代码来源:BlockExplorerFormatter.cs


示例20: GetBlock

		public Block GetBlock(uint256 id, List<byte[]> searchedData)
		{
			Block result = null;
			if(_Blocks.TryGetValue(id, out result))
				return result;
			result = Inner.GetBlock(id, searchedData);
			_Blocks.AddOrUpdate(id, result, (i, b) => b);
			while(_Blocks.Count > MaxCachedBlock)
			{
				var removed = TakeRandom(_Blocks.Keys.ToList());
				Block ignored = null;
				_Blocks.TryRemove(removed, out ignored);
			}
			return result;
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:15,代码来源:CachedBlockProvider.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# umbraco类代码示例发布时间:2022-05-24
下一篇:
C# uLink类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap