コード例 #1
0
 public List<StoredBlock> GetBlocksByHeight(int[] heights)
 {
     using (BlockchainRepository repo = new BlockchainRepository(conn))
     {
         return repo.ReadHeadersWithHeight(heights);
     }
 }
コード例 #2
0
        public BlockLocator GetCurrentChainLocator()
        {
            List<StoredBlock> headers = new List<StoredBlock>();

            using (BlockchainRepository repo = new BlockchainRepository(conn))
            {
                StoredBlock lastBlock = repo.GetLastBlockHeader();
                if (lastBlock != null)
                {
                    headers = repo.ReadHeadersWithHeight(BlockLocator.GetRequiredBlockHeights(lastBlock.Height));
                }
            }

            BlockLocator locator = new BlockLocator();

            foreach (StoredBlock header in headers)
            {
                locator.AddHash(header.Height, header.Hash);
            }

            return locator;
        }
コード例 #3
0
        public StoredBlock FindBlockByHeight(int height)
        {
            using (BlockchainRepository repo = new BlockchainRepository(conn))
            {
                //todo: rewrite this method
                List<StoredBlock> blocks = repo.ReadHeadersWithHeight(new int[] {height});

                if (!blocks.Any())
                {
                    return null;
                }

                return blocks[0];
            }
        }