async Task <Dictionary <Tuple <int, uint, ChainType>, ChainSyncItem> > GetChainSyncItems() { var chains = new List <Chain.Chain> { _chainManager.CoreChain }; chains.AddRange(_chainManager.ServiceChains.Values); chains.AddRange(_chainManager.DataChains.Values); chains.AddRange(_chainManager.MaintainChains.Values); var chainSyncs = new Dictionary <Tuple <int, uint, ChainType>, ChainSyncItem>(); var remotes = new List <RemoteSyncItem>(); foreach (var chain in chains) { var chainType = chain.ChainType; var chainId = chain.ChainId; var chainIndex = chain.ChainIndex; var chainSync = new ChainSyncItem(chain); chainSyncs.Add(new Tuple <int, uint, ChainType>(chainId, chainIndex, chainType), chainSync); Chain.Chain.CreateRequiredDirectories(_storage, chain.ChainType, chainId, chainIndex, true); var endPoints = chain.AvailableEndpoints; foreach (var endPoint in endPoints) { var client = new NodeClient(endPoint.EndPoint); var nodeInfo = endPoint.NodeInfo; if (nodeInfo == null) { nodeInfo = (await client.DownloadNodeInfo(_configuration.NetworkPublicKey)).Data; } if (nodeInfo != null && !(nodeInfo.NodeId == _configuration.LocaleNodeInfo.NodeId)) { if (endPoint.NodeInfo == null) { endPoint.NodeInfo = nodeInfo; } var lastBlockInfo = (await client.DownloadLastBlockInfo(chainType, chainId, chainIndex)).Data; if (lastBlockInfo != null) { var blockSliceInfo = (await client.DownloadBlockStorageSliceInfo(chainType, chainId, chainIndex)).Data; var transactionSliceInfo = (await client.DownloadTransactionStorageSliceInfo(chainType, chainId, chainIndex)).Data; var remote = new RemoteSyncItem(client, lastBlockInfo); chainSync.AddRemote(remote); if (blockSliceInfo != null) { chainSync.UpdateLowestFoundBlockSliceId(blockSliceInfo.FirstStoredSliceId); } if (transactionSliceInfo != null) { chainSync.UpdateLowestFoundTransactionSliceId(transactionSliceInfo.FirstStoredSliceId); } remotes.Add(remote); } } } } // get latest chain info foreach (var chain in chainSyncs.Values) { var chainType = chain.ChainType; var chainId = chain.ChainId; var chainIndex = chain.ChainIndex; foreach (var remote in chain.Remotes) { var lastBlockInfo = (await remote.Client.DownloadLastBlockInfo(chainType, chainId, chainIndex)).Data; chain.UpdateLastBlockInfo(lastBlockInfo); } } return(chainSyncs); }