當前位置: 首頁>>代碼示例>>C#>>正文


C# Block.Verify方法代碼示例

本文整理匯總了C#中Block.Verify方法的典型用法代碼示例。如果您正苦於以下問題:C# Block.Verify方法的具體用法?C# Block.Verify怎麽用?C# Block.Verify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Block的用法示例。


在下文中一共展示了Block.Verify方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestBadTransactions

 public void TestBadTransactions()
 {
     var block = new Block(_params, _blockBytes);
     // Re-arrange so the coinbase transaction is not first.
     var tx1 = block.Transactions[0];
     var tx2 = block.Transactions[1];
     block.Transactions[0] = tx2;
     block.Transactions[1] = tx1;
     try
     {
         block.Verify();
         Assert.Fail();
     }
     catch (VerificationException)
     {
         // We should get here.
     }
 }
開發者ID:Virus-X,項目名稱:CoinSharp,代碼行數:18,代碼來源:BlockTest.cs

示例2: AddBlock

 protected internal override bool AddBlock(Block block)
 {
     lock (block_cache)
     {
         if (!block_cache.ContainsKey(block.Hash))
         {
             block_cache.Add(block.Hash, block);
         }
     }
     lock (header_chain)
     {
         if (!header_chain.Nodes.ContainsKey(block.PrevBlock)) return false;
         if (!header_chain.Nodes.ContainsKey(block.Hash))
         {
             if (VerifyBlocks && !block.Verify()) return false;
             header_chain.Add(block.Hash, block.Header, block.PrevBlock);
             OnAddHeader(block);
         }
     }
     return true;
 }
開發者ID:butine,項目名稱:research,代碼行數:21,代碼來源:LevelDBBlockchain.cs

示例3: GetBlock2

 // Some blocks from the test net.
 private static Block GetBlock2()
 {
     var b2 = new Block(_testNet);
     b2.MerkleRoot = Hex.Decode("addc858a17e21e68350f968ccd384d6439b64aafa6c193c8b9dd66320470838b");
     b2.Nonce = 2642058077;
     b2.Time = 1296734343;
     b2.PrevBlockHash = Hex.Decode("000000033cc282bc1fa9dcae7a533263fd7fe66490f550d80076433340831604");
     Assert.AreEqual("000000037b21cac5d30fc6fda2581cf7b2612908aed2abbcc429c45b0557a15f", b2.HashAsString);
     b2.Verify();
     return b2;
 }
開發者ID:aklein53,項目名稱:bitcoinsharp,代碼行數:12,代碼來源:BlockChainTest.cs

示例4: GetBlock1

 private static Block GetBlock1()
 {
     var b1 = new Block(_testNet);
     b1.MerkleRoot = Hex.Decode("0e8e58ecdacaa7b3c6304a35ae4ffff964816d2b80b62b58558866ce4e648c10");
     b1.Nonce = 236038445;
     b1.Time = 1296734340;
     b1.PrevBlockHash = Hex.Decode("00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008");
     Assert.AreEqual("000000033cc282bc1fa9dcae7a533263fd7fe66490f550d80076433340831604", b1.HashAsString);
     b1.Verify();
     return b1;
 }
開發者ID:aklein53,項目名稱:bitcoinsharp,代碼行數:11,代碼來源:BlockChainTest.cs

示例5: TestBlockVerification

 public void TestBlockVerification()
 {
     var block = new Block(_params, _blockBytes);
     block.Verify();
     Assert.AreEqual("00000000a6e5eb79dcec11897af55e90cd571a4335383a3ccfbc12ec81085935", block.HashAsString);
 }
開發者ID:Virus-X,項目名稱:CoinSharp,代碼行數:6,代碼來源:BlockTest.cs

示例6: TestProofOfWork

 public void TestProofOfWork()
 {
     // This params accepts any difficulty target.
     var networkParams = NetworkParameters.UnitTests();
     var block = new Block(networkParams, _blockBytes);
     block.Nonce = 12346;
     try
     {
         block.Verify();
         Assert.Fail();
     }
     catch (VerificationException)
     {
         // Expected.
     }
     // Blocks contain their own difficulty target. The BlockChain verification mechanism is what stops real blocks
     // from containing artificially weak difficulties.
     block.DifficultyTarget = Block.EasiestDifficultyTarget;
     // Now it should pass.
     block.Verify();
     // Break the nonce again at the lower difficulty level so we can try solving for it.
     block.Nonce = 1;
     try
     {
         block.Verify();
         Assert.Fail();
     }
     catch (VerificationException)
     {
         // Expected to fail as the nonce is no longer correct.
     }
     // Should find an acceptable nonce.
     block.Solve();
     block.Verify();
     Assert.AreEqual(block.Nonce, 2U);
 }
開發者ID:Virus-X,項目名稱:CoinSharp,代碼行數:36,代碼來源:BlockTest.cs


注:本文中的Block.Verify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。