public async Task UpdateSearchRequestStatus(Status newStatus, SourceOption finishedSourceID)
        {
            Status currentStatus = (await GetTheSearchRequest()).TheStatus;

            // Avoid going backwards
            if (newStatus <= currentStatus)
            {
                return;
            }

            // In the case that the Miners are being awaited, progress when all of them have finished
            if (newStatus == Status.Mining_Done)  // If a miner finished
            {
                MiningSource minersLeft = await DecreaseTheSourcesLeft(NewStateNames.TheMinersToFinish, finishedSourceID);

                if (minersLeft.IsEmpty() != true)  // If there are miners that haven't finished yet
                {
                    return;
                }
            }

            // In the case that the Analysers are being awaited, progress when all of them have finished
            if (newStatus == Status.Analysing_Done)  // If an analysers finished
            {
                MiningSource analysersLeft = await DecreaseTheSourcesLeft(NewStateNames.TheAnalysersToFinish, finishedSourceID);

                if (analysersLeft.IsEmpty() != true)  // If there are analysers that haven't finished yet
                {
                    return;
                }
            }

            await SetTheSearchRequestStatus(newStatus);
            await RegisterReminderAsync(ReminderNames.FulfillSReqReminder);
        }
        private async Task <MiningSource> DecreaseTheSourcesLeft(string theSourcesLeftJob, SourceOption finishedSourceID)
        {
            MiningSource sourcesLeft = await GetTheSourcesLeft(theSourcesLeftJob);

            sourcesLeft.RemoveSource(finishedSourceID);
            await SaveTheSourcesLeft(theSourcesLeftJob, sourcesLeft);

            return(sourcesLeft);
        }
        private async Task activateAnalysers(BESearchRequest theSearchRequest)
        {
            MiningSource desiredSources = await GetTheSourcesLeft(NewStateNames.TheAnalysersToCreate);

            Exception exOnAnalyserCall = null;

            foreach (var selectedSource in desiredSources.GetAsList())
            {
                var            analyserUri = AnalyserActorsFactory.GetAnalyserUri(selectedSource);
                IAnalyserActor theAnalyser = ActorProxy.Create <IAnalyserActor>(new ActorId(theSearchRequest.ID), analyserUri);

                try {
                    await theAnalyser.StartAnalysingAsync(theSearchRequest);
                    await DecreaseTheSourcesLeft(NewStateNames.TheAnalysersToCreate, selectedSource);
                } catch (Exception ex) {
                    exOnAnalyserCall = ex;
                }
            }
            if (exOnAnalyserCall != null)  //An Analyser failed
            {
                throw exOnAnalyserCall;
            }
        }
        private async Task SaveTheSourcesLeft(string theSourcesLeftJob, MiningSource minersLeft)
        {
            await StateManager.SetStateAsync(theSourcesLeftJob, new MiningSource( minersLeft ));

            await SaveStateAsync();
        }