Exemplo n.º 1
0
        public async Task UpdateCrossChainDataWithLibAsync(Hash blockHash, long blockHeight)
        {
            if (CrossChainConfigOptions.Value.CrossChainDataValidationIgnored ||
                blockHeight <= AElfConstants.GenesisBlockHeight)
            {
                return;
            }

            _crossChainIndexingDataService.UpdateCrossChainDataWithLib(blockHash, blockHeight);

            var chainIdHeightPairs =
                await _crossChainIndexingDataService.GetAllChainIdHeightPairsAtLibAsync();

            await _crossChainCacheEntityService.UpdateCrossChainCacheAsync(blockHash, blockHeight, chainIdHeightPairs);
        }
        public async Task UpdateCrossChainCacheAsyncTest()
        {
            var chainId = 1;

            _crossChainCacheEntityService.RegisterNewChain(chainId, 10);
            var cachedChainIdList = _crossChainCacheEntityService.GetCachedChainIds();

            cachedChainIdList.ShouldContain(chainId);

            await _crossChainCacheEntityService.UpdateCrossChainCacheAsync(null, 0, new ChainIdAndHeightDict
            {
                IdHeightDict = { { chainId, 12 } }
            });

            var targetHeight = _crossChainCacheEntityService.GetTargetHeightForChainCacheEntity(chainId);

            targetHeight.ShouldBe(13);
        }