public void AddBlockchainFile(BlockchainFile blockchainFile)
 {
     this.adoNetLayer.ExecuteStatementNoResult(
         "INSERT INTO BlockchainFile(BlockchainFileId, BlockchainFileName) VALUES (@BlockchainFileId, @BlockchainFileName)",
         AdoNetLayer.CreateInputParameter("@BlockchainFileId", SqlDbType.Int, blockchainFile.BlockchainFileId),
         AdoNetLayer.CreateInputParameter("@BlockchainFileName", SqlDbType.NVarChar, blockchainFile.BlockchainFileName));
 }
示例#2
0
        /// <summary>
        /// Parses one Bitcoin blockchain file.
        /// </summary>
        /// <param name="blockchainFile">
        /// Contains information about and provides access to the Bitcoin blockchain file that needs to be parsed.
        /// </param>
        /// <returns>
        /// An IEnumerable containing instances of class <see cref="Block"/> each storing data about one Bitcoin block.
        /// </returns>
        private IEnumerable <Block> ParseBlockchainFile(BlockchainFile blockchainFile)
        {
            BinaryReader binaryReader = blockchainFile.BinaryReader;

            while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
            {
                ParserBlock block = this.ParseBlockchainFile(blockchainFile.FileName, binaryReader);
                if (block != null)
                {
                    block.PercentageOfCurrentBlockchainFile = (int)(100 * binaryReader.BaseStream.Position / binaryReader.BaseStream.Length);
                    yield return(block);
                }
            }
        }