本文整理汇总了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();
//.........这里部分代码省略.........