Exemplo n.º 1
0
        public static void pushToMySQL(Block block, DBConnect mysql)
        {
            var mysqlInputList  = new List <Simplifiednput>();
            var mysqlOutputList = new List <SimplifiedOutput>();

            foreach (var transaction in block.Transactions)
            {
                foreach (var input in transaction.inputs)
                {
                    var mysqlInput = new Simplifiednput {
                        TransactionHash                = truncateTransactionHashSixteen(BitConverter.ToString(transaction.thisTransactionHash).Replace("-", String.Empty)),
                        PreviousTransactionHash        = truncateTransactionHashSixteen(BitConverter.ToString(input.PreviousTransactionHash).Replace("-", String.Empty)),
                        PreviousTransactionOutputIndex = input.PreviousTransactionIndex
                    };
                    mysqlInputList.Add(mysqlInput);
                }
                UInt32 outputIndexCounter = 0;
                foreach (var output in transaction.outputs)
                {
                    var mysqlOutput = new SimplifiedOutput {
                        Value           = output.value,
                        PublicAddress   = output.publicKeyAddress,
                        Index           = outputIndexCounter,
                        TransactionHash = truncateTransactionHashSixteen(BitConverter.ToString(transaction.thisTransactionHash).Replace("-", String.Empty)),
                        Timestamp       = block.TimeStamp
                    };
                    mysqlOutputList.Add(mysqlOutput);
                    outputIndexCounter++;
                }
            }

            mysql.InsertInputs(mysqlInputList);
            mysql.InsertOutputs(mysqlOutputList);
        }
Exemplo n.º 2
0
        public static void pushToMySQL(Block block, DBConnect mysql)
        {
            List <Simplifiednput>   mysqlInputList  = new List <Simplifiednput>();
            List <SimplifiedOutput> mysqlOutputList = new List <SimplifiedOutput>();

            foreach (BlockchainTransaction transaction in block.transactions)
            {
                foreach (Input input in transaction.inputs)
                {
                    Simplifiednput mysqlInput = new Simplifiednput();
                    mysqlInput.transactionHash                = truncateTransactionHashSixteen(BitConverter.ToString(transaction.thisTransactionHash).Replace("-", string.Empty));
                    mysqlInput.previousTransactionHash        = truncateTransactionHashSixteen(BitConverter.ToString(input.previousTransactionHash).Replace("-", string.Empty));
                    mysqlInput.previousTransactionOutputIndex = input.previousTransactionIndex;
                    mysqlInputList.Add(mysqlInput);
                }
                uint outputIndexCounter = 0;
                foreach (Output output in transaction.outputs)
                {
                    SimplifiedOutput mysqlOutput = new SimplifiedOutput();
                    mysqlOutput.value           = output.value;
                    mysqlOutput.publicAddress   = output.publicKeyAddress;
                    mysqlOutput.index           = outputIndexCounter;
                    mysqlOutput.transactionHash = truncateTransactionHashSixteen(BitConverter.ToString(transaction.thisTransactionHash).Replace("-", string.Empty));
                    mysqlOutput.timestamp       = block.timeStamp;
                    mysqlOutputList.Add(mysqlOutput);
                    outputIndexCounter++;
                }
            }

            mysql.InsertInputs(mysqlInputList);
            mysql.InsertOutputs(mysqlOutputList);
        }