public async Task AppendRemotableDataAsync(HashSet <Checksum> searchingChecksumsLeft, Dictionary <Checksum, RemotableData> result, CancellationToken cancellationToken)
            {
                var finder = new SolutionChecksumFinder(SolutionState, _serializer, cancellationToken);

                await finder.AppendAsync(searchingChecksumsLeft, result).ConfigureAwait(false);

                if (searchingChecksumsLeft.Count == 0)
                {
                    // there is no checksum left to find
                    return;
                }

                // storage has extra data that we need to search as well
                if (_lazyAdditionalAssets == null)
                {
                    // checksum belongs to global asset
                    return;
                }

                // this will iterate through candidate checksums to see whether that checksum exists in both
                // checksum set we are currently searching for and checksums current node contains
                using var removed = Creator.CreateList <Checksum>();

                var shorterChecksumList = (searchingChecksumsLeft.Count < _lazyAdditionalAssets.Count) ? searchingChecksumsLeft : _lazyAdditionalAssets.Keys;

                // we have 2 sets of checksums. one we are searching for and ones this node contains.
                // we only need to iterate one of them to see this node contains what we are looking for.
                // so, we check two set and use one that has smaller number of checksums.
                foreach (var checksum in shorterChecksumList)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    // given checksum doesn't exist in this additional assets. but will exist
                    // in one of tree nodes/additional assets/global assets
                    if (_lazyAdditionalAssets.TryGetValue(checksum, out var checksumObject) &&
                        searchingChecksumsLeft.Contains(checksum))
                    {
                        // found given checksum in current node
                        result[checksum] = checksumObject;
                        removed.Object.Add(checksum);

                        // we found all checksums we are looking for
                        if (removed.Object.Count == searchingChecksumsLeft.Count)
                        {
                            break;
                        }
                    }
                }

                searchingChecksumsLeft.ExceptWith(removed.Object);
            }
Esempio n. 2
0
 public async Task AppendRemotableDataAsync(HashSet <Checksum> searchingChecksumsLeft, Dictionary <Checksum, RemotableData> result, CancellationToken cancellationToken)
 {
     var finder = new SolutionChecksumFinder(SolutionState, _serializer, cancellationToken);
     await finder.AppendAsync(searchingChecksumsLeft, result).ConfigureAwait(false);
 }