Exemple #1
0
        private void ProcessStateBlocks(CancellationToken ct)
        {
            foreach (RegistryRegisterBlock transactionRegisterBlock in _registryStateBlocks.GetConsumingEnumerable(ct))
            {
                //TODO: add logic that will check whether received Transaction Header was already stored into blockchain

                bool isNew = _registryMemPool.EnqueueTransactionWitness(transactionRegisterBlock);

                if (isNew)
                {
                    IPacketProvider packetProvider = _rawPacketProvidersFactory.Create(transactionRegisterBlock);
                    _udpCommunicationService.PostMessage(_registryGroupState.GetAllNeighbors(), packetProvider);
                }
            }
        }
Exemple #2
0
        private void SendTransactionsBlocks(Tuple <RegistryFullBlock, RegistryShortBlock> tuple)
        {
            RegistryFullBlock  transactionsFullBlock  = tuple.Item1;
            RegistryShortBlock transactionsShortBlock = tuple.Item2;

            ISerializer fullBlockSerializer  = _signatureSupportSerializersFactory.Create(transactionsFullBlock);
            ISerializer shortBlockSerializer = _signatureSupportSerializersFactory.Create(transactionsShortBlock);

            shortBlockSerializer.FillBodyAndRowBytes();
            transactionsFullBlock.ShortBlockHash = _hashCalculation.CalculateHash(transactionsShortBlock.RawData);

            _logger.Debug($"Sending FullBlock with {transactionsFullBlock.TransactionHeaders.Count} transactions and ShortBlock with {transactionsShortBlock.TransactionHeaderHashes.Count} hashes at round {transactionsFullBlock.BlockHeight}");

            _tcpCommunicationService.PostMessage(_registryGroupState.SyncLayerNode, fullBlockSerializer);
            _tcpCommunicationService.PostMessage(_registryGroupState.GetAllNeighbors(), shortBlockSerializer);
        }
Exemple #3
0
        private void SendTransactionsBlocks(RegistryFullBlock transactionsFullBlock, RegistryShortBlock transactionsShortBlock)
        {
            ISerializer fullBlockSerializer  = _serializersFactory.Create(transactionsFullBlock);
            ISerializer shortBlockSerializer = _serializersFactory.Create(transactionsShortBlock);

            shortBlockSerializer.SerializeBody();
            _nodeContext.SigningService.Sign(transactionsShortBlock);

            shortBlockSerializer.SerializeFully();
            transactionsFullBlock.ShortBlockHash = _hashCalculation.CalculateHash(transactionsShortBlock.RawData);

            fullBlockSerializer.SerializeBody();
            _nodeContext.SigningService.Sign(transactionsFullBlock);

            _logger.Debug($"Sending FullBlock with {transactionsFullBlock.StateWitnesses.Length + transactionsFullBlock.UtxoWitnesses.Length} transactions and ShortBlock with {transactionsShortBlock.WitnessStateKeys.Length + transactionsShortBlock.WitnessUtxoKeys.Length} keys at round {transactionsFullBlock.BlockHeight}");

            _tcpCommunicationService.PostMessage(_registryGroupState.SyncLayerNode, fullBlockSerializer);
            _tcpCommunicationService.PostMessage(_registryGroupState.GetAllNeighbors(), shortBlockSerializer);
        }
Exemple #4
0
        private void ProcessBlocks(CancellationToken ct)
        {
            foreach (ITransactionRegistryBlock transactionRegisterBlock in _registrationBlocks.GetConsumingEnumerable(ct))
            {
                if (_timer == null)
                {
                    _timer = new Timer(new TimerCallback(TimerElapsed), _registryMemPool, 120000, Timeout.Infinite);
                }

                //TODO: add logic that will check whether received Transaction Header was already stored into blockchain

                bool isNew = _registryMemPool.EnqueueTransactionRegisterBlock(transactionRegisterBlock);

                if (isNew)
                {
                    IPacketProvider packetProvider = _rawPacketProvidersFactory.Create(transactionRegisterBlock);
                    _udpCommunicationService.PostMessage(_registryGroupState.GetAllNeighbors(), packetProvider);
                }
            }
        }