public SourceDataPipeline() { this.blockLockObject = new object(); this.bitcoinTransactionLockObject = new object(); this.transactionInputLockObject = new object(); this.transactionOutputLockObject = new object(); this.blockDataSet = new BlockDataSet(); this.bitcoinTransactionDataSetBuffer = new BitcoinTransactionDataSet(); this.transactionInputDataSetBuffer = new TransactionInputDataSet(); this.transactionOutputDataSetBuffer = new TransactionOutputDataSet(); this.availableDataTables = new ConcurrentQueue <DataTable>(); }
public SourceDataPipeline() { this.blockLockObject = new object(); this.bitcoinTransactionLockObject = new object(); this.transactionInputLockObject = new object(); this.transactionOutputLockObject = new object(); this.blockDataSet = new BlockDataSet(); this.bitcoinTransactionDataSetBuffer = new BitcoinTransactionDataSet(); this.transactionInputDataSetBuffer = new TransactionInputDataSet(); this.transactionInputSourceDataSetBuffer = new TransactionInputSourceDataSet(); this.transactionOutputDataSetBuffer = new TransactionOutputDataSet(); this.availableDataTables = new ConcurrentQueue<DataTable>(); }
public void FillBlockchainPipeline(int currentBlockchainFileId, ParserData.Block parserBlock, DatabaseIdSegmentManager databaseIdSegmentManager) { long blockId = databaseIdSegmentManager.GetNextBlockId(); lock (this.blockLockObject) { this.blockDataSet.Block.AddBlockRow( blockId, currentBlockchainFileId, (int)parserBlock.BlockHeader.BlockVersion, parserBlock.BlockHeader.BlockHash.ToArray(), parserBlock.BlockHeader.PreviousBlockHash.ToArray(), parserBlock.BlockHeader.BlockTimestamp, (decimal)parserBlock.TransparentSpent / DatabaseGenerator.BtcToSatoshi, (decimal)parserBlock.ShieldedIn / DatabaseGenerator.BtcToSatoshi, (decimal)parserBlock.ShieldedOut / DatabaseGenerator.BtcToSatoshi, (decimal)parserBlock.ShieldedDiff / DatabaseGenerator.BtcToSatoshi, (decimal)parserBlock.BlockReward / DatabaseGenerator.BtcToSatoshi); if (this.MakeDataTableAvailableIfLarge(this.blockDataSet.Block)) { this.blockDataSet = new BlockDataSet(); } } lock (this.bitcoinTransactionLockObject) { foreach (ParserData.Transaction parserTransaction in parserBlock.Transactions) { long bitcoinTransactionId = databaseIdSegmentManager.GetNextTransactionId(); this.bitcoinTransactionDataSetBuffer.BitcoinTransaction.AddBitcoinTransactionRow( bitcoinTransactionId, blockId, parserTransaction.TransactionHash.ToArray(), (int)parserTransaction.TransactionVersion, (int)parserTransaction.TransactionLockTime); } if (this.MakeDataTableAvailableIfLarge(this.bitcoinTransactionDataSetBuffer.BitcoinTransaction)) { this.bitcoinTransactionDataSetBuffer = new BitcoinTransactionDataSet(); } } lock (this.transactionInputLockObject) { databaseIdSegmentManager.ResetNextTransactionId(); foreach (ParserData.Transaction parserTransaction in parserBlock.Transactions) { long bitcoinTransactionId = databaseIdSegmentManager.GetNextTransactionId(); foreach (ParserData.TransactionInput parserTransactionInput in parserTransaction.Inputs) { long transactionInput = databaseIdSegmentManager.GetNextTransactionInputId(); this.transactionInputDataSetBuffer.TransactionInput.AddTransactionInputRow( transactionInput, bitcoinTransactionId, DBData.TransactionInput.SourceTransactionOutputIdUnknown); this.transactionInputSourceDataSetBuffer.TransactionInputSource.AddTransactionInputSourceRow( transactionInput, parserTransactionInput.SourceTransactionHash.ToArray(), (int)parserTransactionInput.SourceTransactionOutputIndex); } if (this.MakeDataTableAvailableIfLarge(this.transactionInputDataSetBuffer.TransactionInput)) { this.transactionInputDataSetBuffer = new TransactionInputDataSet(); } if (this.MakeDataTableAvailableIfLarge(this.transactionInputSourceDataSetBuffer.TransactionInputSource)) { this.transactionInputSourceDataSetBuffer = new TransactionInputSourceDataSet(); } } } lock (this.transactionOutputLockObject) { databaseIdSegmentManager.ResetNextTransactionId(); foreach (ParserData.Transaction parserTransaction in parserBlock.Transactions) { long bitcoinTransactionId = databaseIdSegmentManager.GetNextTransactionId(); for (int outputIndex = 0; outputIndex < parserTransaction.Outputs.Count; outputIndex++) { ParserData.TransactionOutput parserTransactionOutput = parserTransaction.Outputs[outputIndex]; long transactionOutputId = databaseIdSegmentManager.GetNextTransactionOutputId(); this.transactionOutputDataSetBuffer.TransactionOutput.AddTransactionOutputRow( transactionOutputId, bitcoinTransactionId, outputIndex, (decimal)parserTransactionOutput.OutputValueSatoshi / DatabaseGenerator.BtcToSatoshi, parserTransactionOutput.Address); } } if (this.MakeDataTableAvailableIfLarge(this.transactionOutputDataSetBuffer.TransactionOutput)) { this.transactionOutputDataSetBuffer = new TransactionOutputDataSet(); } } lock (this.joinSplitLockObject) { databaseIdSegmentManager.ResetNextTransactionId(); foreach (ParserData.Transaction parserTransaction in parserBlock.Transactions) { long bitcoinTransactionId = databaseIdSegmentManager.GetNextTransactionId(); for (int joinSplitIndex = 0; joinSplitIndex < parserTransaction.JoinSplits.Count; ++joinSplitIndex) { ParserData.JoinSplit parserJoinSplit = parserTransaction.JoinSplits[joinSplitIndex]; long joinSplitId = databaseIdSegmentManager.GetNextJoinSplitId(); this.JoinSplitDataSetBuffer.JoinSplit.AddJoinSplitRow( joinSplitId, bitcoinTransactionId, joinSplitIndex, (decimal)parserJoinSplit.AmountIn / DatabaseGenerator.BtcToSatoshi, (decimal)parserJoinSplit.AmountOut / DatabaseGenerator.BtcToSatoshi); } } if (this.MakeDataTableAvailableIfLarge(this.JoinSplitDataSetBuffer.JoinSplit)) { this.JoinSplitDataSetBuffer = new JoinSplitDataSet(); } } }
public void FillBlockchainPipeline(int currentBlockchainFileId, ParserData.Block parserBlock, DatabaseIdSegmentManager databaseIdSegmentManager) { long blockId = databaseIdSegmentManager.GetNextBlockId(); lock (this.blockLockObject) { this.blockDataSet.Block.AddBlockRow( blockId, currentBlockchainFileId, (int)parserBlock.BlockHeader.BlockVersion, parserBlock.BlockHeader.BlockHash.ToArray(), parserBlock.BlockHeader.PreviousBlockHash.ToArray(), parserBlock.TransactionsCount, parserBlock.BlockHeader.MerkleRootHash.ToArray(), parserBlock.BlockHeader.BlockTimestamp); if (this.MakeDataTableAvailableIfLarge(this.blockDataSet.Block)) { this.blockDataSet = new BlockDataSet(); } } lock (this.bitcoinTransactionLockObject) { foreach (ParserData.Transaction parserTransaction in parserBlock.Transactions) { long bitcoinTransactionId = databaseIdSegmentManager.GetNextTransactionId(); this.bitcoinTransactionDataSetBuffer.BitcoinTransaction.AddBitcoinTransactionRow( bitcoinTransactionId, blockId, parserTransaction.TransactionHash.ToArray(), parserTransaction.TransactionInputsCount, parserTransaction.TransactionOutputsCount, (int)parserTransaction.TransactionVersion, (int)parserTransaction.TransactionLockTime, parserTransaction.IsSegWit); } if (this.MakeDataTableAvailableIfLarge(this.bitcoinTransactionDataSetBuffer.BitcoinTransaction)) { this.bitcoinTransactionDataSetBuffer = new BitcoinTransactionDataSet(); } } lock (this.transactionInputLockObject) { databaseIdSegmentManager.ResetNextTransactionId(); foreach (ParserData.Transaction parserTransaction in parserBlock.Transactions) { long bitcoinTransactionId = databaseIdSegmentManager.GetNextTransactionId(); foreach (ParserData.TransactionInput parserTransactionInput in parserTransaction.Inputs) { long transactionInput = databaseIdSegmentManager.GetNextTransactionInputId(); this.transactionInputDataSetBuffer.TransactionInput.AddTransactionInputRow( transactionInput, bitcoinTransactionId, parserTransactionInput.SourceTransactionHash.ToArray(), (int)parserTransactionInput.SourceTransactionOutputIndex, DBData.TransactionInput.SourceTransactionOutputIdUnknown); } if (this.MakeDataTableAvailableIfLarge(this.transactionInputDataSetBuffer.TransactionInput)) { this.transactionInputDataSetBuffer = new TransactionInputDataSet(); } } } lock (this.transactionOutputLockObject) { databaseIdSegmentManager.ResetNextTransactionId(); foreach (ParserData.Transaction parserTransaction in parserBlock.Transactions) { long bitcoinTransactionId = databaseIdSegmentManager.GetNextTransactionId(); for (int outputIndex = 0; outputIndex < parserTransaction.Outputs.Count; outputIndex++) { ParserData.TransactionOutput parserTransactionOutput = parserTransaction.Outputs[outputIndex]; byte[] temp; temp = parserTransactionOutput.OutputAddress.ToArray(); string str = string.Empty; for (int i = 0; i < temp.Length; i++) { str += (char)temp[i]; } long transactionOutputId = databaseIdSegmentManager.GetNextTransactionOutputId(); this.transactionOutputDataSetBuffer.TransactionOutput.AddTransactionOutputRow( transactionOutputId, bitcoinTransactionId, outputIndex, (decimal)parserTransactionOutput.OutputValueSatoshi / DatabaseGenerator.BtcToSatoshi, parserTransactionOutput.OutputScript.ToArray(), str, DBData.TransactionOutput.OutputAddressIdUnknown); } } if (this.MakeDataTableAvailableIfLarge(this.transactionOutputDataSetBuffer.TransactionOutput)) { this.transactionOutputDataSetBuffer = new TransactionOutputDataSet(); } } }
public void FillBlockchainPipeline(int currentBlockchainFileId, ParserData.Block parserBlock, DatabaseIdSegmentManager databaseIdSegmentManager) { long blockId = databaseIdSegmentManager.GetNextBlockId(); lock (this.blockLockObject) { this.blockDataSet.Block.AddBlockRow( blockId, currentBlockchainFileId, (int)parserBlock.BlockHeader.BlockVersion, parserBlock.BlockHeader.BlockHash.ToArray(), parserBlock.BlockHeader.PreviousBlockHash.ToArray(), parserBlock.BlockHeader.BlockTimestamp); if (this.MakeDataTableAvailableIfLarge(this.blockDataSet.Block)) { this.blockDataSet = new BlockDataSet(); } } lock (this.bitcoinTransactionLockObject) { foreach (ParserData.Transaction parserTransaction in parserBlock.Transactions) { long bitcoinTransactionId = databaseIdSegmentManager.GetNextTransactionId(); this.bitcoinTransactionDataSetBuffer.BitcoinTransaction.AddBitcoinTransactionRow( bitcoinTransactionId, blockId, parserTransaction.TransactionHash.ToArray(), (int)parserTransaction.TransactionVersion, (int)parserTransaction.TransactionLockTime); } if (this.MakeDataTableAvailableIfLarge(this.bitcoinTransactionDataSetBuffer.BitcoinTransaction)) { this.bitcoinTransactionDataSetBuffer = new BitcoinTransactionDataSet(); } } lock (this.transactionInputLockObject) { databaseIdSegmentManager.ResetNextTransactionId(); foreach (ParserData.Transaction parserTransaction in parserBlock.Transactions) { long bitcoinTransactionId = databaseIdSegmentManager.GetNextTransactionId(); foreach (ParserData.TransactionInput parserTransactionInput in parserTransaction.Inputs) { long transactionInput = databaseIdSegmentManager.GetNextTransactionInputId(); this.transactionInputDataSetBuffer.TransactionInput.AddTransactionInputRow( transactionInput, bitcoinTransactionId, DBData.TransactionInput.SourceTransactionOutputIdUnknown); this.transactionInputSourceDataSetBuffer.TransactionInputSource.AddTransactionInputSourceRow( transactionInput, parserTransactionInput.SourceTransactionHash.ToArray(), (int)parserTransactionInput.SourceTransactionOutputIndex); } if (this.MakeDataTableAvailableIfLarge(this.transactionInputDataSetBuffer.TransactionInput)) { this.transactionInputDataSetBuffer = new TransactionInputDataSet(); } if (this.MakeDataTableAvailableIfLarge(this.transactionInputSourceDataSetBuffer.TransactionInputSource)) { this.transactionInputSourceDataSetBuffer = new TransactionInputSourceDataSet(); } } } lock (this.transactionOutputLockObject) { databaseIdSegmentManager.ResetNextTransactionId(); foreach (ParserData.Transaction parserTransaction in parserBlock.Transactions) { long bitcoinTransactionId = databaseIdSegmentManager.GetNextTransactionId(); for (int outputIndex = 0; outputIndex < parserTransaction.Outputs.Count; outputIndex++) { ParserData.TransactionOutput parserTransactionOutput = parserTransaction.Outputs[outputIndex]; long transactionOutputId = databaseIdSegmentManager.GetNextTransactionOutputId(); this.transactionOutputDataSetBuffer.TransactionOutput.AddTransactionOutputRow( transactionOutputId, bitcoinTransactionId, outputIndex, (decimal)parserTransactionOutput.OutputValueSatoshi / DatabaseGenerator.BtcToSatoshi, parserTransactionOutput.OutputScript.ToArray()); } } if (this.MakeDataTableAvailableIfLarge(this.transactionOutputDataSetBuffer.TransactionOutput)) { this.transactionOutputDataSetBuffer = new TransactionOutputDataSet(); } } }