示例#1
0
        void Awake()
        {
            HotReload.Register(this);

            _pipeIn  = new PipeIn();
            _pipeOut = new PipeOut();

#if UNITY_STANDALONE_WIN
            _pipeInAbsolutePath  = @"\\.\pipe\" + _pipeInName + Shell.Main.ID;
            _pipeOutAbsolutePath = @"\\.\pipe\" + _pipeOutName + Shell.Main.ID;
#else
            _pipeInAbsolutePath  = Application.dataPath + "/../" + _pipeInName + Shell.Main.ID;
            _pipeOutAbsolutePath = Application.dataPath + "/../" + _pipeOutName + Shell.Main.ID;
#endif
        }
示例#2
0
        public UserIdentitiesUpdater(long accountId, IUtxoClientCryptoService clientCryptoService,
                                     IAssetsService assetsService, IDataAccessService dataAccessService,
                                     IHubContext <IdentitiesHub> idenitiesHubContext, IRelationsProofsValidationService relationsProofsValidationService,
                                     ISchemeResolverService schemeResolverService, ILoggerService loggerService, CancellationToken cancellationToken)
        {
            _accountId           = accountId;
            _clientCryptoService = clientCryptoService;
            _assetsService       = assetsService;
            _dataAccessService   = dataAccessService;
            _idenitiesHubContext = idenitiesHubContext;
            _relationsProofsValidationService = relationsProofsValidationService;
            _schemeResolverService            = schemeResolverService;
            _cancellationToken = cancellationToken;

            _cancellationToken.Register(() =>
            {
                PipeIn?.Complete();
                PipInNotifications?.Complete();
            });

            _logger = loggerService.GetLogger(nameof(UserIdentitiesUpdater));
            PipeIn  = new ActionBlock <PacketBase>(async p =>
            {
                try
                {
                    if (p is TransferAssetToUtxo packet)
                    {
                        _logger.LogIfDebug(() => $"[{_accountId}]: Processing {nameof(TransferAssetToUtxo)}");
                        UserRootAttribute userRootAttribute = _dataAccessService.GetRootAttributeByOriginalCommitment(_accountId, packet.TransferredAsset.AssetCommitment);
                        if (userRootAttribute != null)
                        {
                            _clientCryptoService.DecodeEcdhTuple(packet.TransferredAsset.EcdhTuple, packet.TransactionPublicKey, out byte[] blindingFactor, out byte[] assetId);
                            await _assetsService.GetAttributeSchemeName(assetId, packet.Signer.ToString()).ContinueWith(t =>
                            {
                                if (t.IsCompleted && !t.IsFaulted)
                                {
                                    _idenitiesHubContext.Clients.Group(_accountId.ToString(CultureInfo.InvariantCulture))
                                    .SendAsync("PushAttribute",
                                               new UserAttributeDto
                                    {
                                        SchemeName  = t.Result,
                                        Source      = packet.Signer.ToString(),
                                        Content     = userRootAttribute.Content,
                                        Validated   = true,
                                        IsOverriden = false
                                    });
                                }
                            }, TaskScheduler.Current).ConfigureAwait(false);

                            await ObtainRelations(packet, assetId).ConfigureAwait(false);

                            await ObtainRegistrations(packet, assetId).ConfigureAwait(false);
                        }
                        else
                        {
                            _logger.Error($"[{_accountId}]: No Root Attribute found by commitment {packet.TransferredAsset.AssetCommitment.ToHexString()}");
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error($"Failure during processing {nameof(PipeIn)}, packet {p?.GetType().Name}", ex);
                }
            });

            PipInNotifications = new ActionBlock <SynchronizerNotificationBase>(n =>
            {
                try
                {
                    _logger.LogIfDebug(() => $"[{_accountId}]: notification {n.GetType().Name} {JsonConvert.SerializeObject(n, new ByteArrayJsonConverter())}");

                    ProcessEligibilityCommitmentsDisabled(n);

                    NotifyUserAttributeLastUpdate(n);

                    NotifyCompromisedKeyImage(n);
                }
                catch (Exception ex)
                {
                    _logger.Error($"Failure during processing {nameof(PipInNotifications)}, notification {n?.GetType().Name}", ex);
                }
            });
        }
示例#3
0
        public ServiceProviderUpdater(long accountId,
                                      IStateClientCryptoService clientCryptoService,
                                      IAssetsService assetsService,
                                      ISchemeResolverService schemeResolverService,
                                      IDataAccessService dataAccessService,
                                      IIdentityAttributesService identityAttributesService,
                                      IBlockParsersRepositoriesRepository blockParsersRepositoriesRepository,
                                      IGatewayService gatewayService,
                                      IStateTransactionsService transactionsService,
                                      ISpValidationsService spValidationsService,
                                      IHubContext <IdentitiesHub> idenitiesHubContext,
                                      ILoggerService loggerService,
                                      IConsentManagementService consentManagementService,
                                      IUniversalProofsPool universalProofsPool,
                                      CancellationToken cancellationToken)
        {
            _accountId                          = accountId;
            _clientCryptoService                = clientCryptoService;
            _assetsService                      = assetsService;
            _schemeResolverService              = schemeResolverService;
            _dataAccessService                  = dataAccessService;
            _identityAttributesService          = identityAttributesService;
            _blockParsersRepositoriesRepository = blockParsersRepositoriesRepository;
            _gatewayService                     = gatewayService;
            _transactionsService                = transactionsService;
            _spValidationsService               = spValidationsService;
            _idenitiesHubContext                = idenitiesHubContext;
            _consentManagementService           = consentManagementService;
            _universalProofsPool                = universalProofsPool;
            _cancellationToken                  = cancellationToken;
            _logger = loggerService.GetLogger(nameof(ServiceProviderUpdater));

            _cancellationToken.Register(() =>
            {
                PipeIn?.Complete();
                PipInNotifications?.Complete();
            });

            PipeIn = new ActionBlock <PacketBase>(async p =>
            {
                if (p == null)
                {
                    _logger.Error($"[{_accountId}]: Obtained NULL packet");
                    return;
                }

                _logger.Info($"[{_accountId}]: Obtained {p.GetType().Name} packet");

                try
                {
                    if (p is DocumentSignRecord documentSignRecord)
                    {
                        ProcessDocumentSignRecord(documentSignRecord);
                    }

                    if (p is DocumentRecord documentRecord)
                    {
                        ProcessDocumentRecord(documentRecord);
                    }

                    if (p is DocumentSignRequest documentSignRequest)
                    {
                        ProcessDocumentSignRequest(documentSignRequest);
                    }

                    if (p is EmployeeRegistrationRequest employeeRegistrationRequest)
                    {
                        ProcessEmployeeRegistrationRequest(employeeRegistrationRequest);
                    }

                    if (p is IdentityProofs packet)
                    {
                        await ProcessIdentityProofs(packet).ConfigureAwait(false);
                    }

                    if (p is TransitionCompromisedProofs compromisedProofs)
                    {
                        ProcessCompromisedProofs(new Key32(compromisedProofs.CompromisedKeyImage));
                    }

                    if (p is TransferAsset transferAsset)
                    {
                        ProcessTransferAsset(transferAsset);
                    }

                    if (p is UniversalTransport universalTransport)
                    {
                        await ProcessUniversalTransport(universalTransport).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error($"[{_accountId}]: Failed to process packet {p.GetType().Name}", ex);
                }
            });
        }