Beispiel #1
0
        public override async Task RequestIndexingFromSideChain(CrossChainRequest crossChainRequest,
                                                                IServerStreamWriter <SideChainBlockData> responseStream, ServerCallContext context)
        {
            Logger.LogDebug("Side Chain Server received IndexedInfo message.");
            var requestedHeight = crossChainRequest.NextHeight;

            while (requestedHeight - crossChainRequest.NextHeight <
                   CrossChainCommunicationConstants.MaximalIndexingCount)
            {
                var sideChainBlock = await _crossChainResponseService.ResponseSideChainBlockDataAsync(requestedHeight);

                if (sideChainBlock == null)
                {
                    break;
                }
                try
                {
                    await responseStream.WriteAsync(sideChainBlock);

                    requestedHeight++;
                }
                catch (InvalidOperationException)
                {
                    Logger.LogWarning("Failed to write into server side stream.");
                    return;
                }
            }
        }
Beispiel #2
0
        public override async Task RequestIndexingFromSideChain(CrossChainRequest crossChainRequest,
                                                                IServerStreamWriter <SideChainBlockData> responseStream, ServerCallContext context)
        {
            Logger.LogTrace("Side Chain Server received IndexedInfo message.");
            var requestedHeight = crossChainRequest.NextHeight;

            while (requestedHeight - crossChainRequest.NextHeight < CrossChainCommunicationConstants.MaximalIndexingCount)
            {
                var sideChainBlock = await _crossChainResponseService.ResponseSideChainBlockDataAsync(requestedHeight);

                if (sideChainBlock == null)
                {
                    break;
                }
                await responseStream.WriteAsync(sideChainBlock);

                requestedHeight++;
            }
        }
        public async Task ResponseSideChainBlockData_Test()
        {
            var res = await _chainResponseService.ResponseSideChainBlockDataAsync(2);

            Assert.True(res.Height == 2);
        }