Example #1
0
        /* BLOCK MANAGEMENT */
        // Conduct Proof-of-work in order to mine transactions from the pool and submit a new block to the Blockchain
        private void NewBlock_Click(object sender, EventArgs e)
        {
            // Retrieve pending transactions to be added to the newly generated Block
            List <Transaction> transactions = blockchain.GetPendingTransactions();

            for (int i = 0; i < transactions.Count; i++)
            {
                Console.WriteLine("Before sorting: {0}", transactions[i].Feeamount());
            }
            if (UserSettings == 0)
            {
                transactions.Sort(delegate(Transaction a, Transaction b)
                {
                    return(a.timecreated().CompareTo(b.timecreated())); // returns the longest transactions
                });
            }
            else if (UserSettings == 2)
            {
                transactions.Sort(delegate(Transaction a, Transaction b)
                {
                    return(b.Feeamount().CompareTo(a.Feeamount()));
                    // returns the transaction based on fee amount
                });
            }
            for (int i = 0; i < transactions.Count; i++)
            {
                Console.WriteLine("After sorting: {0}", transactions[i].Feeamount());
            }
            // Create and append the new block - requires a reference to the previous block, a set of transactions and the miners public address (For the reward to be issued)
            Block newBlock = new Block(blockchain.GetLastBlock(), transactions, publicKey.Text);

            blockchain.blocks.Add(newBlock);

            UpdateText(blockchain.ToString());
        }
Example #2
0
        //Mines block
        private void newBlock_Click(object sender, EventArgs e)
        {
            List <Transaction> transactions = blockchain.getPendingTransactions();
            Block newBlock = new Block(blockchain.GetLastBlock(), transactions, publicKey.Text);

            blockchain.Blocks.Add(newBlock);

            richTextBox1.Text = blockchain.ToString();
        }
        private void newBlock_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("hello    " + comboBox1.SelectedIndex);
            //List<Transaction> transactions = blockchain.getPendingTransactions();
            List <Transaction> transactions = blockchain.gettransactionPool(comboBox1.SelectedIndex, publicKey.Text);
            //System.Diagnostics.Debug.WriteLine(transactions[0].fee);
            Block newBlock = new Block(blockchain.GetLastBlock(), transactions, _Form1, publicKey.Text);

            blockchain.Blocks.Add(newBlock);
            richTextBox1.Text = blockchain.ToString();
        }
        /* BLOCK MANAGEMENT */
        // Conduct Proof-of-work in order to mine transactions from the pool and submit a new block to the Blockchain
        private void NewBlock_Click(object sender, EventArgs e)
        {
            // Retrieve pending transactions to be added to the newly generated Block
            List <Transaction> transactions = blockchain.GetPendingTransactions();

            // Create and append the new block - requires a reference to the previous block, a set of transactions and the miners public address (For the reward to be issued)
            Block newBlock = new Block(blockchain.GetLastBlock(), transactions, publicKey.Text);

            blockchain.blocks.Add(newBlock);

            UpdateText(blockchain.ToString());
        }
        private void newBlock_Click(object sender, EventArgs e)
        {
            int threads;

            if (!int.TryParse(numThreads.Text, out threads))
            {
                threads = 1;
            }

            if (threads < 1)
            {
                threads = 1;                // Use at least one thread
            }
            threads = Math.Min(threads, 6); // Don't use more threads than cores.


            List <Transaction> transactions = blockchain.GetPendingTransactions(preferenceCombo.Text, publicKey.Text);
            Block newBlock = new Block(blockchain.GetLastBlock(), transactions, publicKey.Text, threads, target: 0x000ffff000000000);

            blockchain.Blocks.Add(newBlock);

            richTextBox1.Text = blockchain.ToString();
        }
Example #6
0
        private void BlockGenBtn_Click(object sender, EventArgs e)
        {
            Block block = new Block(blockchain.GetLastBlock());

            blockchain.add2Block(block);
        }