Example #1
0
        // IBlockchainSynchronizer
        public override void addConsumer(IBlockchainConsumer consumer)
        {
            Debug.Assert(consumer != null);
            Debug.Assert(m_consumers.count(consumer) == 0);

            if (!(checkIfStopped() && checkIfShouldStop()))
            {
                var message = "Failed to add consumer: not stopped";
                m_logger.functorMethod(ERROR, BRIGHT_RED) << message << ", consumer " << consumer;
                throw new System.Exception(message);
            }

            m_consumers.Add(consumer, new SynchronizationState(m_genesisBlockHash));
            m_logger.functorMethod(INFO, BRIGHT_WHITE) << "Consumer added, consumer " << consumer << ", count " << m_consumers.Count;
        }
Example #2
0
//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#:
//ORIGINAL LINE: virtual ClassicVector<Crypto::Hash> getConsumerKnownBlocks(IBlockchainConsumer& consumer) const override
        public override List <Crypto.Hash> getConsumerKnownBlocks(IBlockchainConsumer consumer)
        {
            std::unique_lock <object> lk = new std::unique_lock <object>(m_consumersMutex);

            var state = getConsumerSynchronizationState(consumer);

            if (state == null)
            {
                var message = "Failed to get consumer known blocks: not found";
                m_logger.functorMethod(ERROR, BRIGHT_RED) << message << ", consumer " << consumer;
                throw new System.ArgumentException(message);
            }

            return(state.getKnownBlockHashes());
        }
Example #3
0
        public override bool removeConsumer(IBlockchainConsumer consumer)
        {
            Debug.Assert(consumer != null);

            if (!(checkIfStopped() && checkIfShouldStop()))
            {
                var message = "Failed to remove consumer: not stopped";
                m_logger.functorMethod(ERROR, BRIGHT_RED) << message << ", consumer " << consumer;
                throw new System.Exception(message);
            }

            bool result = m_consumers.Remove(consumer) > 0;

            if (result)
            {
                m_logger.functorMethod(INFO, BRIGHT_WHITE) << "Consumer removed, consumer " << consumer << ", count " << m_consumers.Count;
            }
            else
            {
                m_logger.functorMethod(ERROR, BRIGHT_RED) << "Failed to remove consumer: not found, consumer " << consumer;
            }

            return(result);
        }
Example #4
0
//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#:
//ORIGINAL LINE: virtual IStreamSerializable* getConsumerState(IBlockchainConsumer* consumer) const override
        public override IStreamSerializable getConsumerState(IBlockchainConsumer consumer)
        {
            std::unique_lock <object> lk = new std::unique_lock <object>(m_consumersMutex);

            return(getConsumerSynchronizationState(consumer));
        }