Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="transaction"></param>
        public void ProcessTransaction(Transaction transaction)
        {
            transaction.RunHash();
            transactionPool.AddTransaction(transaction);

            // send on network
            if (client != null)
            {
                client.Send(transaction.Serialise());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Set client from server
        /// </summary>
        /// <param name="e"></param>
        private void SetClientFromServer(ClientFromServerEventArgs e)
        {
            client.client = e.client;
            Task clientConnection = Task.Run(() => client.StartReceiving());

            // Send current Hash on network
            client.Send($"U:{lewCoins.GetLatestBlock().hash},{lewCoins.GetLatestBlock().index}");
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        public void MineBlock()
        {
            candidateBlock = new Block(DateTime.Now, "", transactionPool.pendingTransactions);
            candidateBlock.previousHash = currentHash;
            candidateBlock.index        = currentIndex;

            // This will block the thread in future when we make hashing take purposely longer
            candidateBlock.MineHash("Lew");

            // Candidate block complete, send on network
            client.Send(candidateBlock.Serialise());
        }