Exemple #1
0
            public ProcessingTestContext(bool startProcessor)
            {
                _logger = _logManager.GetClassLogger();
                MemDb blockDb     = new MemDb();
                MemDb blockInfoDb = new MemDb();
                MemDb headersDb   = new MemDb();
                Block genesis     = Build.A.Block.Genesis.TestObject;

                _blockTree      = new BlockTree(blockDb, headersDb, blockInfoDb, new ChainLevelInfoRepository(blockInfoDb), MainnetSpecProvider.Instance, NullBloomStorage.Instance, LimboLogs.Instance);
                _blockProcessor = new BlockProcessorMock(_logManager);
                _recoveryStep   = new RecoveryStepMock(_logManager);
                _processor      = new BlockchainProcessor(_blockTree, _blockProcessor, _recoveryStep, LimboLogs.Instance, BlockchainProcessor.Options.Default);
                _resetEvent     = new AutoResetEvent(false);

                _blockTree.NewHeadBlock += (sender, args) =>
                {
                    _logger.Info($"Finished waiting for {args.Block.ToString(Block.Format.Short)} as block became the new head block");
                    _resetEvent.Set();
                };

                if (startProcessor)
                {
                    _processor.Start();
                }
            }
Exemple #2
0
            public ProcessingTestContext()
            {
                _logger = _logManager.GetClassLogger();
                MemDb blockDb     = new MemDb();
                MemDb blockInfoDb = new MemDb();
                MemDb headersDb   = new MemDb();

                _blockTree      = new BlockTree(blockDb, headersDb, blockInfoDb, new ChainLevelInfoRepository(blockInfoDb), MainNetSpecProvider.Instance, NullTxPool.Instance, LimboLogs.Instance);
                _blockProcessor = new BlockProcessorMock(_logManager);
                _recoveryStep   = new RecoveryStepMock(_logManager);
                _processor      = new BlockchainProcessor(_blockTree, _blockProcessor, _recoveryStep, LimboLogs.Instance, true, true);
                _resetEvent     = new AutoResetEvent(false);

                _blockTree.NewHeadBlock += (sender, args) =>
                {
                    _logger.Info($"Finished waiting for {args.Block.ToString(Block.Format.Short)} as block became the new head block");
                    _resetEvent.Set();
                };

                _processor.Start();
            }
            public ProcessingTestContext()
            {
                MemDb blockDb     = new MemDb();
                MemDb blockInfoDb = new MemDb();

                _blockTree      = new BlockTree(blockDb, blockInfoDb, MainNetSpecProvider.Instance, NullTransactionPool.Instance, NullLogManager.Instance);
                _blockProcessor = new BlockProcessorMock();
                _recoveryStep   = new RecoveryStepMock();
                _processor      = new BlockchainProcessor(_blockTree, _blockProcessor, _recoveryStep, NullLogManager.Instance, true, true);
                _resetEvent     = new AutoResetEvent(false);
//                _blockProcessor.BlockProcessed += (sender, args) =>
//                {
//                    Console.WriteLine($"Finished waiting for {args.Block.ToString(Block.Format.Short)} as block was processed");
//                    _resetEvent.Set();
//                };

                _blockTree.NewHeadBlock += (sender, args) =>
                {
                    Console.WriteLine($"Finished waiting for {args.Block.ToString(Block.Format.Short)} as block became the new head block");
                    _resetEvent.Set();
                };

                _processor.Start();
            }