public void RegisterNewChainTest() { var chainId = 1; _crossChainCacheEntityService.RegisterNewChain(chainId, 1); var cachedChainIdList = _crossChainCacheEntityService.GetCachedChainIds(); cachedChainIdList.ShouldContain(chainId); _crossChainCacheEntityService.GetCachedChainIds(); var targetHeight = _crossChainCacheEntityService.GetTargetHeightForChainCacheEntity(chainId); targetHeight.ShouldBe(2); }
public async Task RequestCrossChainDataTest() { var crossChainClientCreationContext = new CrossChainClientCreationContext { LocalChainId = 0, RemoteChainId = 1, IsClientToParentChain = false, RemoteServerHost = "localhost", RemoteServerPort = 5000 }; var communicationHelper = GetRequiredService <CrossChainCommunicationTestHelper>(); communicationHelper.SetClientConnected(crossChainClientCreationContext.RemoteChainId, true); await _crossChainClientService.CreateClientAsync(crossChainClientCreationContext); _crossChainCacheEntityService.RegisterNewChain(crossChainClientCreationContext.RemoteChainId, 10); communicationHelper.CheckClientConnected(-1).ShouldBeFalse(); await _crossChainRequestService.RequestCrossChainDataFromOtherChainsAsync(); communicationHelper.CheckClientConnected(-1).ShouldBeTrue(); var chainInitializationData = await _crossChainRequestService.RequestChainInitializationDataAsync(crossChainClientCreationContext.RemoteChainId); chainInitializationData.CreationHeightOnParentChain.ShouldBe(1); }
public async Task FinishInitialSyncAsync() { CrossChainConfigOptions.CurrentValue.CrossChainDataValidationIgnored = false; var isReadyToCreateChainCache = await _irreversibleBlockStateProvider.ValidateIrreversibleBlockExistingAsync(); if (!isReadyToCreateChainCache) { return; } var libIdHeight = await _irreversibleBlockStateProvider.GetLastIrreversibleBlockHashAndHeightAsync(); var chainIdHeightPairs = await GetAllChainIdHeightPairsAsync(libIdHeight.BlockHash, libIdHeight.BlockHeight); foreach (var chainIdHeight in chainIdHeightPairs.IdHeightDict) { // register new chain _crossChainCacheEntityService.RegisterNewChain(chainIdHeight.Key, chainIdHeight.Value); } }
public async Task FinishInitialSyncAsync() { CrossChainConfigOptions.Value.CrossChainDataValidationIgnored = false; var chainIdHeightPairs = await _crossChainIndexingDataService.GetAllChainIdHeightPairsAtLibAsync(); foreach (var chainIdHeight in chainIdHeightPairs.IdHeightDict) { // register new chain _crossChainCacheEntityService.RegisterNewChain(chainIdHeight.Key, chainIdHeight.Value); } }
public async Task RegisterNewChainsAsync(Hash blockHash, long blockHeight) { if (CrossChainConfigOptions.CurrentValue.CrossChainDataValidationIgnored || blockHeight <= Constants.GenesisBlockHeight) { return; } var sideChainIdHeightPairs = await GetAllChainIdHeightPairsAsync(blockHash, blockHeight); foreach (var chainIdHeightPair in sideChainIdHeightPairs.IdHeightDict) { _crossChainCacheEntityService.RegisterNewChain(chainIdHeightPair.Key, chainIdHeightPair.Value); } }