public static SharpChainBlock IndexOfBlock(SharpChain sc, string Hash, bool CopyEx, List <SharpChainIndex> parsedIndexes = null) // Get Entire Block via Index of Block Hash { if (parsedIndexes == null) { parsedIndexes = SharpChainIndex.ParseSharpChainIndexList(sc, 0, true); } SharpChainIndex index = null; try { index = parsedIndexes.First((p) => p.Hash == Hash); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Could not find hash index!"); } if (index != null) { List <SharpChainBlock> blocks = sc.ReadBlocks(false, true, index.Start, index.Length); return(blocks.Count > 0 ? blocks[0] : null); } return(null); }
public SharpChainBlock GetLastBlock(SharpChain sc, bool CopyEx) // Get the Last Block { List <SharpChainIndex> parsedIndexes = SharpChainIndex.ParseSharpChainIndexList(sc, 0, CopyEx); if (parsedIndexes.Count > 0) { var cnt = parsedIndexes.Count - 1; var hash = parsedIndexes[cnt].Hash; return(SharpChainIndex.IndexOfBlock(sc, hash, CopyEx, parsedIndexes)); } return(null); }