Пример #1
0
        public void UpdateSourceTransactionId()
        {
            const long maxBatchSize = 10000000;

            Stopwatch updateTransactionSourceOutputWatch = new Stopwatch();

            updateTransactionSourceOutputWatch.Start();

            Console.Write("Setting direct links: inputs to source outputs (this may take a long time)...");

            using (BitcoinDataLayer bitcoinDataLayer = new BitcoinDataLayer(this.databaseConnection.ConnectionString, BitcoinDataLayer.ExtendedDbCommandTimeout))
            {
                long rowsToUpdateCommand = bitcoinDataLayer.GetTransactionSourceRowsToUpdate();
                long batchSize           = rowsToUpdateCommand / 10;
                batchSize = batchSize >= 1 ? batchSize : 1;
                batchSize = batchSize <= maxBatchSize ? batchSize : maxBatchSize;

                long totalRowsUpdated = bitcoinDataLayer.UpdateNullTransactionSources();
                Console.Write("\rSetting direct links: inputs to source outputs (this may take a long time)... {0}%", 95 * totalRowsUpdated / rowsToUpdateCommand);

                int rowsUpdated;
                while ((rowsUpdated = bitcoinDataLayer.UpdateTransactionSourceBatch(batchSize)) > 0)
                {
                    totalRowsUpdated += rowsUpdated;
                    Console.Write("\rSetting direct links: inputs to source outputs (this may take a long time)... {0}%", 95 * totalRowsUpdated / rowsToUpdateCommand);
                }
                bitcoinDataLayer.FixupTransactionSourceIdForDuplicateTransactionHash();
            }
            updateTransactionSourceOutputWatch.Stop();

            Console.WriteLine("\rSetting direct links: inputs to source outputs completed in {0:0.000} seconds.          ", updateTransactionSourceOutputWatch.Elapsed.TotalSeconds);
        }
        private void UpdateTransactionSourceOutputId()
        {
            const long maxBatchSize = 10000000;

            Stopwatch updateTransactionSourceOutputWatch = new Stopwatch();
            updateTransactionSourceOutputWatch.Start();

            Console.Write("Setting direct links: inputs to source outputs...");

            using (BitcoinDataLayer bitcoinDataLayer = new BitcoinDataLayer(this.databaseConnection.ConnectionString, BitcoinDataLayer.ExtendedDbCommandTimeout))
            {
                long rowsToUpdateCommand = bitcoinDataLayer.GetTransactionSourceOutputRowsToUpdate();

                long batchSize = rowsToUpdateCommand / 10;
                batchSize = batchSize >= 1 ? batchSize : 1;
                batchSize = batchSize <= maxBatchSize ? batchSize : maxBatchSize;

                long totalRowsUpdated = bitcoinDataLayer.UpdateNullTransactionSources();
                Console.Write("\rSetting direct links: inputs to source outputs... {0}%", 95 * totalRowsUpdated / rowsToUpdateCommand);

                int rowsUpdated;
                while ((rowsUpdated = bitcoinDataLayer.UpdateTransactionSourceBatch(batchSize)) > 0)
                {
                    totalRowsUpdated += rowsUpdated;
                    Console.Write("\rSetting direct links: inputs to source outputs... {0}%", 95 * totalRowsUpdated / rowsToUpdateCommand);
                }

                bitcoinDataLayer.FixupTransactionSourceOutputIdForDuplicateTransactionHash();
            }

            updateTransactionSourceOutputWatch.Stop();

            Console.WriteLine("\rSetting direct links: inputs to source outputs completed in {0:0.000} seconds.", updateTransactionSourceOutputWatch.Elapsed.TotalSeconds);
        }