public async Task ValidateAnnouncement_Success() { var chain = await _blockchainService.GetChainAsync(); var blockAnnouncement = new BlockAnnouncement { BlockHash = Hash.FromString("SyncBlockHash"), BlockHeight = chain.LastIrreversibleBlockHeight + 1 }; var validateResult = await _blockSyncValidationService.ValidateAnnouncementBeforeSyncAsync(chain, blockAnnouncement, GetEncodedPubKeyString()); validateResult.ShouldBeTrue(); }
private async Task ProcessNewBlockAsync(BlockAnnouncement blockAnnouncement, string senderPubkey) { var chain = await _blockchainService.GetChainAsync(); if (!await _blockSyncValidationService.ValidateAnnouncementBeforeSyncAsync(chain, blockAnnouncement, senderPubkey)) { return; } await _blockSyncService.SyncByAnnouncementAsync(chain, new SyncAnnouncementDto { SyncBlockHash = blockAnnouncement.BlockHash, SyncBlockHeight = blockAnnouncement.BlockHeight, SuggestedPeerPubkey = senderPubkey, BatchRequestBlockCount = _blockSyncOptions.MaxBatchRequestBlockCount }); }
private async Task ProcessNewBlockAsync(BlockAnnouncement blockAnnouncement, string senderPubkey) { Logger.LogDebug( $"Start block sync job, target height: {blockAnnouncement.BlockHeight}, target block hash: {blockAnnouncement.BlockHash}, peer: {senderPubkey}"); var chain = await _blockchainService.GetChainAsync(); if (!await _blockSyncValidationService.ValidateAnnouncementBeforeSyncAsync(chain, blockAnnouncement, senderPubkey)) { return; } await _blockSyncService.SyncByAnnouncementAsync(chain, new SyncAnnouncementDto { SyncBlockHash = blockAnnouncement.BlockHash, SyncBlockHeight = blockAnnouncement.BlockHeight, SuggestedPeerPubkey = senderPubkey, BatchRequestBlockCount = _blockSyncOptions.MaxBatchRequestBlockCount }); }