Example #1
0
        public TransactionsRegistryHandler(IStatesRepository statesRepository, IServerCommunicationServicesRegistry communicationServicesRegistry,
                                           IRawPacketProvidersFactory rawPacketProvidersFactory, IRegistryMemPool registryMemPool, IConfigurationService configurationService,
                                           IHashCalculationsRepository hashCalculationRepository, ISerializersFactory signatureSupportSerializersFactory, ILoggerService loggerService)
        {
            _registrationBlocks                 = new BlockingCollection <ITransactionRegistryBlock>();
            _registryGroupState                 = statesRepository.GetInstance <IRegistryGroupState>();
            _synchronizationContext             = statesRepository.GetInstance <ISynchronizationContext>();
            _nodeContext                        = statesRepository.GetInstance <INodeContext>();
            _communicationServicesRegistry      = communicationServicesRegistry;
            _rawPacketProvidersFactory          = rawPacketProvidersFactory;
            _registryMemPool                    = registryMemPool;
            _configurationService               = configurationService;
            _signatureSupportSerializersFactory = signatureSupportSerializersFactory;
            _defaulHashCalculation              = hashCalculationRepository.Create(Globals.DEFAULT_HASH);
            _powCalculation                     = hashCalculationRepository.Create(Globals.POW_TYPE);
            _logger = loggerService.GetLogger(nameof(TransactionsRegistryHandler));

            TransformBlock <RegistryShortBlock, RegistryConfidenceBlock> produceConfidenceBlock = new TransformBlock <RegistryShortBlock, RegistryConfidenceBlock>((Func <RegistryShortBlock, RegistryConfidenceBlock>)GetConfidence);
            ActionBlock <RegistryConfidenceBlock> sendConfidenceBlock = new ActionBlock <RegistryConfidenceBlock>((Action <RegistryConfidenceBlock>)SendConfidence);

            produceConfidenceBlock.LinkTo(sendConfidenceBlock);
            _transactionsRegistryConfidenceFlow = produceConfidenceBlock;

            ActionBlock <RegistryConfirmationBlock> confirmationProcessingBlock = new ActionBlock <RegistryConfirmationBlock>((Action <RegistryConfirmationBlock>)ProcessConfirmationBlock);

            _confirmationBlockFlow = confirmationProcessingBlock;
        }
Example #2
0
        public TransactionsRegistryService(IStatesRepository statesRepository, IPredicatesRepository predicatesRepository, IRegistryMemPool registryMemPool,
                                           IIdentityKeyProvidersRegistry identityKeyProvidersRegistry, ICryptoService cryptoService, IConfigurationService configurationService,
                                           IServerCommunicationServicesRegistry serverCommunicationServicesRegistry, IPerformanceCountersRepository performanceCountersRepository,
                                           ISerializersFactory signatureSupportSerializersFactory, ITransactionsRegistryHelper transactionsRegistryHelper, IHashCalculationsRepository hashCalculationsRepository, ILoggerService loggerService)
        {
            _synchronizationContext              = statesRepository.GetInstance <ISynchronizationContext>();
            _registryGroupState                  = statesRepository.GetInstance <IRegistryGroupState>();
            _isBlockProducerPredicate            = predicatesRepository.GetInstance("IsBlockProducer");
            _transactionHashKey                  = identityKeyProvidersRegistry.GetTransactionsIdenityKeyProvider();
            _cryptoService                       = cryptoService;
            _configurationService                = configurationService;
            _serverCommunicationServicesRegistry = serverCommunicationServicesRegistry;
            _signatureSupportSerializersFactory  = signatureSupportSerializersFactory;
            _transactionsRegistryHelper          = transactionsRegistryHelper;
            _powCalculation                      = hashCalculationsRepository.Create(Globals.POW_TYPE);
            _hashCalculation                     = hashCalculationsRepository.Create(Globals.DEFAULT_HASH);
            _logger = loggerService.GetLogger(nameof(TransactionsRegistryService));
            TransformBlock <IRegistryMemPool, SortedList <ushort, ITransactionRegistryBlock> > deduplicateAndOrderTransactionRegisterBlocksBlock = new TransformBlock <IRegistryMemPool, SortedList <ushort, ITransactionRegistryBlock> >((Func <IRegistryMemPool, SortedList <ushort, ITransactionRegistryBlock> >)DeduplicateAndOrderTransactionRegisterBlocks);
            TransformBlock <SortedList <ushort, ITransactionRegistryBlock>, RegistryFullBlock> produceTransactionsFullBlock = new TransformBlock <SortedList <ushort, ITransactionRegistryBlock>, RegistryFullBlock>((Func <SortedList <ushort, ITransactionRegistryBlock>, RegistryFullBlock>)ProduceTransactionsFullBlock);
            ActionBlock <Tuple <RegistryFullBlock, RegistryShortBlock> > sendTransactionsBlocks = new ActionBlock <Tuple <RegistryFullBlock, RegistryShortBlock> >((Action <Tuple <RegistryFullBlock, RegistryShortBlock> >)SendTransactionsBlocks);
            TransformBlock <RegistryFullBlock, Tuple <RegistryFullBlock, RegistryShortBlock> > produceTransactionsShortBlock = new TransformBlock <RegistryFullBlock, Tuple <RegistryFullBlock, RegistryShortBlock> >((Func <RegistryFullBlock, Tuple <RegistryFullBlock, RegistryShortBlock> >)ProduceTransactionsShortBlock);

            deduplicateAndOrderTransactionRegisterBlocksBlock.LinkTo(produceTransactionsFullBlock);
            produceTransactionsFullBlock.LinkTo(produceTransactionsShortBlock);
            produceTransactionsShortBlock.LinkTo(sendTransactionsBlocks);

            _transactionsRegistryProducingFlow = deduplicateAndOrderTransactionRegisterBlocksBlock;


            _registryMemPool = registryMemPool;

            _nodeCountersService = performanceCountersRepository.GetInstance <NodeCountersService>();
        }
Example #3
0
        public TransactionsRegistryHandler(IStatesRepository statesRepository, IServerCommunicationServicesRegistry communicationServicesRegistry,
                                           IRawPacketProvidersFactory rawPacketProvidersFactory, IRegistryMemPool registryMemPool, IConfigurationService configurationService,
                                           IHashCalculationsRepository hashCalculationRepository, ILoggerService loggerService)
        {
            _registryStateBlocks           = new BlockingCollection <RegistryRegisterBlock>();
            _registryUtxoBlocks            = new BlockingCollection <RegistryRegisterUtxoConfidential>();
            _registryGroupState            = statesRepository.GetInstance <IRegistryGroupState>();
            _synchronizationContext        = statesRepository.GetInstance <ISynchronizationContext>();
            _nodeContext                   = statesRepository.GetInstance <INodeContext>();
            _communicationServicesRegistry = communicationServicesRegistry;
            _rawPacketProvidersFactory     = rawPacketProvidersFactory;
            _registryMemPool               = registryMemPool;
            _configurationService          = configurationService;
            _defaulHashCalculation         = hashCalculationRepository.Create(Globals.DEFAULT_HASH);
            _powCalculation                = hashCalculationRepository.Create(Globals.POW_TYPE);
            _logger = loggerService.GetLogger(nameof(TransactionsRegistryHandler));

            _processWitnessedFlow = new ActionBlock <RegistryShortBlock>((Action <RegistryShortBlock>)ProcessWitnessed);
        }
Example #4
0
        public TransactionsRegistryService(IStatesRepository statesRepository, IPredicatesRepository predicatesRepository, IRegistryMemPool registryMemPool,
                                           IIdentityKeyProvidersRegistry identityKeyProvidersRegistry, IConfigurationService configurationService,
                                           IServerCommunicationServicesRegistry serverCommunicationServicesRegistry, IPerformanceCountersRepository performanceCountersRepository,
                                           ISerializersFactory serializersFactory, IHashCalculationsRepository hashCalculationsRepository, ILoggerService loggerService)
        {
            _configurationService                = configurationService;
            _synchronizationContext              = statesRepository.GetInstance <ISynchronizationContext>();
            _registryGroupState                  = statesRepository.GetInstance <IRegistryGroupState>();
            _nodeContext                         = statesRepository.GetInstance <INodeContext>();
            _isBlockProducerPredicate            = predicatesRepository.GetInstance("IsBlockProducer");
            _transactionHashKey                  = identityKeyProvidersRegistry.GetTransactionsIdenityKeyProvider();
            _serverCommunicationServicesRegistry = serverCommunicationServicesRegistry;
            _serializersFactory                  = serializersFactory;
            _powCalculation                      = hashCalculationsRepository.Create(Globals.POW_TYPE);
            _hashCalculation                     = hashCalculationsRepository.Create(Globals.DEFAULT_HASH);
            _logger = loggerService.GetLogger(nameof(TransactionsRegistryService));

            _registryMemPool = registryMemPool;

            _nodeCountersService = performanceCountersRepository.GetInstance <NodeCountersService>();
        }
Example #5
0
 public UtxoConfidentialStorageHandler(IStatesRepository statesRepository, IServerCommunicationServicesRegistry communicationServicesRegistry, IRawPacketProvidersFactory rawPacketProvidersFactory, IRegistryMemPool registryMemPool, IConfigurationService configurationService, IHashCalculationsRepository hashCalculationRepository, IChainDataServicesManager chainDataServicesManager) : base(statesRepository, communicationServicesRegistry, rawPacketProvidersFactory, registryMemPool, configurationService, hashCalculationRepository, chainDataServicesManager)
 {
 }
Example #6
0
 public StorageHandlerBase(IStatesRepository statesRepository, IServerCommunicationServicesRegistry communicationServicesRegistry, IRawPacketProvidersFactory rawPacketProvidersFactory, IRegistryMemPool registryMemPool, IConfigurationService configurationService, IHashCalculationsRepository hashCalculationRepository, IChainDataServicesManager chainDataServicesManager)
 {
     _nodeContext = statesRepository.GetInstance <INodeContext>();
     _communicationServicesRegistry = communicationServicesRegistry;
     _chainDataServicesManager      = chainDataServicesManager;
 }
Example #7
0
        private SortedList <ushort, ITransactionRegistryBlock> DeduplicateAndOrderTransactionRegisterBlocks(IRegistryMemPool memPool)
        {
            SortedList <ushort, ITransactionRegistryBlock> transactionRegisterBlocks = memPool.DequeueBulk(-1);

            //TODO: Remove debug code
            if (transactionRegisterBlocks.Count > 0)
            {
            }

            return(transactionRegisterBlocks);
        }