当前位置: 首页>>代码示例>>C++>>正文


C++ unordered_multimap::clear方法代码示例

本文整理汇总了C++中std::unordered_multimap::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_multimap::clear方法的具体用法?C++ unordered_multimap::clear怎么用?C++ unordered_multimap::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::unordered_multimap的用法示例。


在下文中一共展示了unordered_multimap::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: daemonThreadFunc

/// Process data from bitcoind daemon (esp. RPC getrawmempool for live transactions)
void daemonThreadFunc(BlockChain* blockChain)
{
	leveldb::WriteBatch batch;

	while (true)
	{
		std::this_thread::sleep_for(std::chrono::seconds(1));

		if (requestedQuit)
			break;

		if (!txCheck)
			continue;

		try
		{
			auto transactions = rpcClient->CallMethod("getrawmempool", Json::Value());

			BlockInfo blockInfo;
			Hash256 latestBlock;
			{
				boost::lock_guard<boost::mutex> guard(chainMutex);
				latestBlock = currentChain.back();

				auto blockInfoIt = blocks.find(latestBlock);
				if (blockInfoIt == blocks.end())
				{
					continue;
				}
				blockInfo = blockInfoIt->second;
			}

			if (pendingPreviousBlock != latestBlock)
			{
				pendingPreviousBlock = latestBlock;

				// Broadcast new block for live update
				Json::Value blockResult;
				blockResult["item"] = "block";
				convertBlock(blockResult, pendingPreviousBlock, blockInfo);
				websocket_server.broadcast_livetx(blockResult.toStyledString().c_str());

				{
					boost::lock_guard<boost::mutex> guard(pendingTransactionsMutex);
					pendingTransactionIndices.clear();
					pendingTransactions.clear();
					pendingTransactionsByAddress.clear();
				}
			}

			for (auto tx = transactions.begin(); tx != transactions.end(); ++tx)
			{
				Hash256 txHash;
				encodeHexString((uint8_t*) &txHash, 32, (*tx).asString(), true);

				batch.Clear();

				{
					// Already exists?
					boost::unique_lock<boost::mutex> guard(pendingTransactionsMutex);
					if (pendingTransactionIndices.find(txHash) != pendingTransactionIndices.end())
						continue;
				}

				{
					DbTransaction dbTx;

					Json::Value parameters(Json::arrayValue);
					parameters.append(*tx);
					auto rawTx = rpcClient->CallMethod("getrawtransaction", parameters);

					auto data = rawTx.asCString();
					auto bufferLength = strlen(data) / 2;

					llvm::SmallVector<uint8_t, 65536> buffer;
					buffer.resize(bufferLength);

					encodeHexString(buffer.begin(), bufferLength, data);

					BlockChain::BlockTransaction tx2;
					if (!blockChain->processSingleTransaction(buffer.begin(), bufferLength, tx2))
						assert("could not read tx" && false);

					assert(memcmp(tx2.transactionHash, &txHash, 32) == 0);
					uint64_t totalOutput = 0;
					bool needBroadcast = false;

					auto txIndex = dbHelper.txLoad(txHash, dbTx, NULL, NULL);
					if (txIndex == 0)
					{
						{
							boost::unique_lock<boost::mutex> guard(pendingTransactionsMutex);
							try
							{
								txIndex = processTransaction(batch, dbTx, tx2, time(NULL), false, &pendingTransactionIndices, &pendingTransactions);
							}
							catch (std::exception e)
							{
								batch.Clear();
//.........这里部分代码省略.........
开发者ID:Bushstar,项目名称:bkchaind,代码行数:101,代码来源:BitcoinLiveTX.cpp


注:本文中的std::unordered_multimap::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。