private async Task BroadCastExecuteAsync(BlockBundle block)
        {
            Debug.WriteLine($"Sending block {block.Block.Signed.Data.Index}");
            var response = await _httpClient.PostAsJsonAsync(ApiConstants.Block, block);

            Debug.WriteLine($"Block {block.Block.Signed.Data.Index} sent");
            DebugResponse(response);
        }
Beispiel #2
0
 public Task AcceptBlockAsync(BlockBundle block)
 {
     if (block?.Block != null)
     {
         _minerSync.Reset();
         var blockchainState = _chainData.AddNewBlock(block.Block);
         //Cancel miner only after new block was accepted
         _currentMiner?.Cancel();
         if (blockchainState == BlockchainState.NeedSync)
         {
             StartBlockchainSync(() => _minerSync.Set());
         }
         else
         {
             _minerSync.Set();
         }
         return(Task.CompletedTask);
     }
     throw new BlockchainException("Cannot accept NULL block");
 }
 //[HttpPost(ApiConstants.Blocks)]
 public async Task BroadcastAsync([FromBody] BlockBundle block)
 {
     await _engine.AcceptBlockAsync(block);
 }
 public Task BroadcastAsync(BlockBundle block) =>
 QueueBroadcast(() => BroadCastExecuteAsync(block));