Example #1
0
        public async Task MineBlock(string minerAddress)
        {
            var minerRewardTransaction = new Transaction(null, minerAddress, _miningReward);

            _pendingTransactions.Add(minerRewardTransaction);
            var prevHash = Chain.Last().Hash;
            var block    = new BlockchainAPI.Block.Implementations.Block(_pendingTransactions, prevHash);

            block.MineBlock(_proofOfWorkDifficulty);
            Chain.Add(block);
            await _blockRepository.Insert(block);

            _pendingTransactions = new List <Transaction>();
            Console.WriteLine("Block has been mined");
        }