Example #1
0
        public async Task QuerySubscriptions()
        {
            if (_subBusy)
            {
                return;
            }

            _subBusy = true;
            var lastTransactionInfo = (await Fan.DownloadFanofLastTransactionInfo(ServiceNode.Client, ChainType.Data, ServiceNode.ChainId, StatusServiceInfo.FanChainIndex, ServiceNode.AccountId))?.Item;

            if (lastTransactionInfo == null)
            {
                goto end;
            }

            var download = false;

            if (_subscriptionLastTransaction == null)
            {
                download = true;
            }
            else
            {
                if (lastTransactionInfo.TransactionId > _subscriptionLastTransaction.TransactionId)
                {
                    download = true;
                }
            }

            if (download)
            {
                var fanInfo = (await Fan.DownloadFanOf(ServiceNode.Client, ChainType.Data, ServiceNode.ChainId, StatusServiceInfo.FanChainIndex, ServiceNode.AccountId))?.Item;
                if (fanInfo == null)
                {
                    goto end;
                }

                _subscriptionLastTransaction = lastTransactionInfo;

                await _subscriptions.ProcessSubscriptions(fanInfo);
                await QueryMissingProfiles();

                await SaveAsync();

                //await ServiceNode.TransactionDownloadManager.UpdateLastAccess(id);
            }

end:
            _subBusy = false;
        }