2d53bbaaab9f70e935e6b8191189e1fb4e2c03e4
[NovacoinLibrary.git] / Novacoin / Checkpoints.cs
1 using System;
2
3 namespace Novacoin
4 {
5     public class Checkpoints
6     {
7         private static Tuple<uint, uint256, uint>[] checkpoints = new Tuple<uint, uint256, uint>[]
8             {
9                 new Tuple<uint, uint256, uint>(0, NetInfo.nHashGenesisBlock, 1360105017)
10             };
11
12         /// <summary>
13         /// Last checkpoint height.
14         /// </summary>
15         public static uint TotalBlocksEstimate { get { return checkpoints[checkpoints.Length - 1].Item1; } }
16
17         /// <summary>
18         /// Last checkpoint timestamp.
19         /// </summary>
20         public static uint LastCheckpointTime { get { return checkpoints[checkpoints.Length - 1].Item3; } }
21
22         /// <summary>
23         /// Block hash verification.
24         /// </summary>
25         /// <param name="nHeight">Block height.</param>
26         /// <param name="nBlockHash">Block hash.</param>
27         /// <returns></returns>
28         public static bool Verify(uint nHeight, uint256 nBlockHash)
29         {
30             foreach (var checkpoint in checkpoints)
31             {
32                 if (checkpoint.Item1 == nHeight)
33                 {
34                     return nBlockHash == checkpoint.Item2;
35                 }
36             }
37
38             return true;
39         }
40     }
41 }