src/Stratis.FederatedPeg.Features.FederationGateway/TargetChain/CrossChainTransferStore.cs
/// <summary>Synchronize with a batch of blocks.</summary>
/// <returns>Returns <c>true</c> if we match the chain tip and <c>false</c> if we are behind the tip.</returns>
Synchronize with a batch of blocks.
Synchronize with a batch of blocks .
private bool SynchronizeBatch()
        {
            var blockHashes = new List<uint256>();
            int batchSize = 0;
            HashHeightPair tipToChase = this.TipToChase();
            foreach (ChainedHeader header in this.chain.EnumerateToTip(this.TipHashAndHeight.HashBlock).Skip(1))
            {
                if (this.chain.GetBlock(header.HashBlock) == null)
                    break;
                if (header.Height > tipToChase.Height)
                    break;
                blockHashes.Add(header.HashBlock);
                if (++batchSize >= synchronizationBatchSize)
                    break;
            }
            List<Block> blocks = this.blockRepository.GetBlocksAsync(blockHashes).GetAwaiter().GetResult();
            int availableBlocks = blocks.FindIndex(b => (b == null));
            if (availableBlocks < 0)
                availableBlocks = blocks.Count;
            if (availableBlocks > 0)
            {
                Block lastBlock = blocks[availableBlocks - 1];
                this.Put(blocks.GetRange(0, availableBlocks));
                this.logger.LogInformation("Synchronized {0} blocks with cross-chain store to advance tip to block {1}", availableBlocks, this.TipHashAndHeight?.Height);
            }
            bool done = availableBlocks < synchronizationBatchSize;
            return done;
        }
private bool SynchronizeBatch ( ) { var blockHashes = new List < uint256 > ( ) ; int batchSize = 0 ; HashHeightPair tipToChase = this . TipToChase ( ) ; foreach ( ChainedHeader header in this . chain . EnumerateToTip ( this . TipHashAndHeight . HashBlock ) . Skip ( 1 ) ) { if ( this . chain . GetBlock ( header . HashBlock ) == null ) break ; if ( header . Height > tipToChase . Height ) break ; blockHashes . Add ( header . HashBlock ) ; if ( ++ batchSize >= synchronizationBatchSize ) break ; } List < Block > blocks = this . blockRepository . GetBlocksAsync ( blockHashes ) . GetAwaiter ( ) . GetResult ( ) ; int availableBlocks = blocks . FindIndex ( b => ( b == null ) ) ; if ( availableBlocks < 0 ) availableBlocks = blocks . Count ; if ( availableBlocks > 0 ) { Block lastBlock = blocks [ availableBlocks - 1 ] ; this . Put ( blocks . GetRange ( 0 , availableBlocks ) ) ; this . logger . LogInformation ( " " , availableBlocks , this . TipHashAndHeight ? . Height ) ; } bool done = availableBlocks < synchronizationBatchSize ; return done ; }
Synchronize with a batch of blocks.
Synchronize with a batch of blocks .
// Get a batch of blocks.
None