public void waitBlockchainUpdate() { m_logger.functorMethod(Logging.Level.DEBUGGING) << "Waiting for blockchain updates"; m_stopped = false; Crypto.Hash lastBlockHash = requestLastBlockHash(); while (!m_stopped) { //C++ TO C# CONVERTER TODO TASK: Only lambda expressions having all locals passed by reference can be converted to C#: //ORIGINAL LINE: m_sleepingContext.spawn([this]() m_sleepingContext.spawn(() => { System.Timer timer = new System.Timer(m_dispatcher); timer.sleep(std::chrono.seconds(m_pollingInterval)); }); m_sleepingContext.wait(); if (lastBlockHash != requestLastBlockHash()) { m_logger.functorMethod(Logging.Level.DEBUGGING) << "Blockchain has been updated"; break; } } if (m_stopped) { m_logger.functorMethod(Logging.Level.DEBUGGING) << "Blockchain monitor has been stopped"; throw System.InterruptedException(); } }
public void start() { m_logger.functorMethod(Logging.Level.DEBUGGING) << "starting"; BlockMiningParameters @params = new BlockMiningParameters(); for (;;) { m_logger.functorMethod(Logging.Level.INFO) << "requesting mining parameters"; try { //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: params = requestMiningParameters(m_dispatcher, m_config.daemonHost, m_config.daemonPort, m_config.miningAddress); @params.CopyFrom(requestMiningParameters(m_dispatcher, m_config.daemonHost, m_config.daemonPort, m_config.miningAddress)); } catch (ConnectException e) { m_logger.functorMethod(Logging.Level.WARNING) << "Couldn't connect to daemon: " << e.what(); System.Timer timer = new System.Timer(m_dispatcher); timer.sleep(std::chrono.seconds(m_config.scanPeriod)); continue; } adjustBlockTemplate(@params.blockTemplate); break; } isRunning = true; startBlockchainMonitoring(); std::thread reporter = new std::thread(std::bind(this.printHashRate, this)); startMining(@params); eventLoop(); isRunning = false; }