示例#1
0
        public PacketHandlingFlow(int iteration, ICoreVerifiersBulkFactory coreVerifiersBulkFactory,
                                  IPacketVerifiersRepository packetTypeHandlersFactory, IBlockParsersRepositoriesRepository blockParsersFactoriesRepository,
                                  IBlocksHandlersRegistry blocksProcessorFactory, IPerformanceCountersRepository performanceCountersRepository, ILoggerService loggerService)
        {
            _coreVerifiers = coreVerifiersBulkFactory.Create();
            _log           = loggerService.GetLogger($"{nameof(PacketHandlingFlow)}#{iteration}");
            _blockParsersFactoriesRepository    = blockParsersFactoriesRepository;
            _chainTypeValidationHandlersFactory = packetTypeHandlersFactory;
            _blocksHandlersRegistry             = blocksProcessorFactory;

            _decodeBlock = new TransformBlock <byte[], byte[]>((Func <byte[], byte[]>)DecodeMessage, new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = 1, BoundedCapacity = 1000000
            });
            _parseBlock = new TransformBlock <byte[], BlockBase>((Func <byte[], BlockBase>)ParseMessagePacket, new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = 1, BoundedCapacity = 1000000
            });
            _processBlock = new ActionBlock <BlockBase>((Action <BlockBase>)DispatchBlock, new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = 1, BoundedCapacity = 1000000
            });
            _endToEndCountersService = performanceCountersRepository.GetInstance <EndToEndCountersService>();

            _decodeBlock.LinkTo(_parseBlock);
            _parseBlock.LinkTo(_processBlock);
        }
示例#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>();
        }
示例#3
0
        public PacketsHandler(IPacketVerifiersRepository packetTypeHandlersFactory, IBlockParsersRepositoriesRepository blockParsersFactoriesRepository, IBlocksHandlersRegistry blocksProcessorFactory, ICoreVerifiersBulkFactory coreVerifiersBulkFactory, IPerformanceCountersRepository performanceCountersRepository, ILoggerService loggerService)
        {
            _log                     = loggerService.GetLogger(GetType().Name);
            _messagePackets          = new BlockingCollection <byte[]>();
            _endToEndCountersService = performanceCountersRepository.GetInstance <EndToEndCountersService>();

            _maxDegreeOfParallelism = 4;

            _handlingFlows = new PacketHandlingFlow[_maxDegreeOfParallelism];

            for (int i = 0; i < _maxDegreeOfParallelism; i++)
            {
                _handlingFlows[i] = new PacketHandlingFlow(i, coreVerifiersBulkFactory, packetTypeHandlersFactory, blockParsersFactoriesRepository, blocksProcessorFactory, performanceCountersRepository, loggerService);
            }
        }
示例#4
0
 public LoadModuleBase(ILoggerService loggerService, IClientCommunicationServiceRepository clientCommunicationServiceRepository,
                       IConfigurationService configurationService, IIdentityKeyProvidersRegistry identityKeyProvidersRegistry,
                       ISerializersFactory signatureSupportSerializersFactory, INodesDataService nodesDataService, ICryptoService cryptoService,
                       IPerformanceCountersRepository performanceCountersRepository, IHashCalculationsRepository hashCalculationRepository)
     : base(loggerService)
 {
     _communicationService = clientCommunicationServiceRepository.GetInstance(nameof(TcpClientCommunicationService));
     _configurationService = configurationService;
     _signatureSupportSerializersFactory = signatureSupportSerializersFactory;
     _nodesDataService       = nodesDataService;
     _cryptoService          = cryptoService;
     _identityKeyProvider    = identityKeyProvidersRegistry.GetInstance();
     _loadCountersService    = performanceCountersRepository.GetInstance <LoadCountersService>();
     _hashCalculation        = hashCalculationRepository.Create(Globals.DEFAULT_HASH);
     _proofOfWorkCalculation = hashCalculationRepository.Create(Globals.POW_TYPE);
 }
示例#5
0
        public CommunicationChannel(ILoggerService loggerService, IPerformanceCountersRepository performanceCountersRepository)
        {
            _log            = loggerService.GetLogger(GetType().Name);
            _packets        = new BlockingCollection <byte[]>();
            _postedMessages = new ConcurrentQueue <byte[]>();
            _socketReceiveAsyncEventArgs            = new SocketAsyncEventArgs();
            _socketReceiveAsyncEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(Receive_Completed);
            _socketSendAsyncEventArgs            = new SocketAsyncEventArgs();
            _socketSendAsyncEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(Send_Completed);
            _socketAcceptedEvent = new ManualResetEventSlim(false);
            _socketSendEvent     = new ManualResetEventSlim();

            _memoryStream = new MemoryStream();
            _binaryWriter = new BinaryWriter(_memoryStream);

            _communicationCountersService = performanceCountersRepository?.GetInstance <CommunicationCountersService>();
        }
示例#6
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>();
        }
示例#7
0
 public SimulationLoadInitializer(IPerformanceCountersRepository performanceCountersRepository)
 {
     _loadCountersService = performanceCountersRepository.GetInstance <LoadCountersService>();
 }