这篇教程C++ AssertLockHeld函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中AssertLockHeld函数的典型用法代码示例。如果您正苦于以下问题:C++ AssertLockHeld函数的具体用法?C++ AssertLockHeld怎么用?C++ AssertLockHeld使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了AssertLockHeld函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: AssertLockHeldvoid CInstantSend::UpdateLockedTransaction(const CTxLockCandidate& txLockCandidate){ // cs_wallet and cs_instantsend should be already locked#ifdef ENABLE_WALLET if (pwalletMain) AssertLockHeld(pwalletMain->cs_wallet);#endif AssertLockHeld(cs_instantsend); uint256 txHash = txLockCandidate.GetHash(); if(!IsLockedInstantSendTransaction(txHash)) return; // not a locked tx, do not update/notify#ifdef ENABLE_WALLET if(pwalletMain && pwalletMain->UpdatedTransaction(txHash)) { // bumping this to update UI nCompleteTXLocks++; // notify an external script once threshold is reached std::string strCmd = GetArg("-instantsendnotify", ""); if(!strCmd.empty()) { boost::replace_all(strCmd, "%s", txHash.GetHex()); boost::thread t(runCommand, strCmd); // thread runs free } }#endif GetMainSignals().NotifyTransactionLock(*txLockCandidate.txLockRequest.tx); LogPrint("instantsend", "CInstantSend::UpdateLockedTransaction -- done, txid=%s/n", txHash.ToString());}
开发者ID:einalex,项目名称:syscoin,代码行数:30,
示例2: IsRBFOptInbool IsRBFOptIn(const CTxMemPoolEntry &entry, CTxMemPool &pool){ AssertLockHeld(pool.cs); CTxMemPool::setEntries setAncestors; // First check the transaction itself. if (SignalsOptInRBF(entry.GetTx())) { return true; } // If this transaction is not in our mempool, then we can't be sure // we will know about all its inputs. if (!pool.exists(entry.GetTx().GetHash())) { throw std::runtime_error("Cannot determine RBF opt-in signal for non-mempool transaction/n"); } // If all the inputs have nSequence >= maxint-1, it still might be // signaled for RBF if any unconfirmed parents have signaled. uint64_t noLimit = std::numeric_limits<uint64_t>::max(); std::string dummy; pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false); BOOST_FOREACH(CTxMemPool::txiter it, setAncestors) { if (SignalsOptInRBF(it->GetTx())) { return true; } } return false;}
开发者ID:deuscoin-org,项目名称:deuscoin-core,代码行数:30,
示例3: AssertLockHeldbool CMasternodeBroadcast::CheckOutpoint(int& nDos){ // we are a masternode with the same outpoint (i.e. already activated) and this mnb is ours (matches our Masternode privkey) // so nothing to do here for us if (fMasternodeMode && outpoint == activeMasternode.outpoint && pubKeyMasternode == activeMasternode.pubKeyMasternode) { return false; } AssertLockHeld(cs_main); int nHeight; CollateralStatus err = CheckCollateral(outpoint, pubKeyCollateralAddress, nHeight); if (err == COLLATERAL_UTXO_NOT_FOUND) { LogPrint(MCLog::MN, "CMasternodeBroadcast::CheckOutpoint -- Failed to find Masternode UTXO, masternode=%s/n", outpoint.ToStringShort()); return false; } if (err == COLLATERAL_INVALID_AMOUNT) { LogPrint(MCLog::MN, "CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO should have 1000 DASH, masternode=%s/n", outpoint.ToStringShort()); nDos = 33; return false; } if (err == COLLATERAL_INVALID_PUBKEY) { LogPrint(MCLog::MN, "CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO should match pubKeyCollateralAddress, masternode=%s/n", outpoint.ToStringShort()); nDos = 33; return false; } if (chainActive.Height() - nHeight + 1 < Params().GetConsensus().nMasternodeMinimumConfirmations) { LogPrintf("CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO must have at least %d confirmations, masternode=%s/n", Params().GetConsensus().nMasternodeMinimumConfirmations, outpoint.ToStringShort()); // UTXO is legit but has not enough confirmations. // Maybe we miss few blocks, let this mnb be checked again later. mnodeman.mapSeenMasternodeBroadcast.erase(GetHash()); return false; } LogPrint(MCLog::MN, "CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO verified/n"); // Verify that sig time is legit, should be at least not earlier than the timestamp of the block // at which collateral became nMasternodeMinimumConfirmations blocks deep. // NOTE: this is not accurate because block timestamp is NOT guaranteed to be 100% correct one. CBlockIndex* pRequiredConfIndex = chainActive[nHeight + Params().GetConsensus().nMasternodeMinimumConfirmations - 1]; // block where tx got nMasternodeMinimumConfirmations if (pRequiredConfIndex->GetBlockTime() > sigTime) { LogPrintf("CMasternodeBroadcast::CheckOutpoint -- Bad sigTime %d (%d conf block is at %d) for Masternode %s %s/n", sigTime, Params().GetConsensus().nMasternodeMinimumConfirmations, pRequiredConfIndex->GetBlockTime(), outpoint.ToStringShort(), addr.ToString()); return false; } if (!CheckSignature(nDos)) { LogPrintf("CMasternodeBroadcast::CheckOutpoint -- CheckSignature() failed, masternode=%s/n", outpoint.ToStringShort()); return false; } // remember the block hash when collateral for this masternode had minimum required confirmations nCollateralMinConfBlockHash = pRequiredConfIndex->GetBlockHash(); return true;}
开发者ID:machinecoin-project,项目名称:machinecoin-core,代码行数:60,
示例4: AssertLockHeldQString TransactionDesc::FormatTxStatus(const CWalletTx& wtx){ AssertLockHeld(cs_main); if (!CheckFinalTx(wtx)) { if (wtx.nLockTime < LOCKTIME_THRESHOLD) return tr("Open for %n more block(s)", "", wtx.nLockTime - chainActive.Height()); else return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.nLockTime)); } else { int nDepth = wtx.GetDepthInMainChain(); if (nDepth < 0) return tr("conflicted with a transaction with %1 confirmations").arg(-nDepth); else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) return tr("%1/offline").arg(nDepth); else if (nDepth == 0) return tr("0/unconfirmed, %1").arg((wtx.InMempool() ? tr("in memory pool") : tr("not in memory pool"))) + (wtx.isAbandoned() ? ", "+tr("abandoned") : ""); else if (nDepth < 6) return tr("%1/unconfirmed").arg(nDepth); else return tr("%1 confirmations").arg(nDepth); }}
开发者ID:tlc2,项目名称:bitcredit-2.0-client,代码行数:25,
示例5: AssertLockHeldvoid CTxMemPool::RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason) { AssertLockHeld(cs); UpdateForRemoveFromMempool(stage, updateDescendants); for (const txiter& it : stage) { removeUnchecked(it, reason); }}
开发者ID:994920256,项目名称:bitcoin,代码行数:7,
示例6: AssertLockHeldvoidCNameMemPool::removeConflicts (const CTransaction& tx, std::list<CTransaction>& removed){ AssertLockHeld (pool.cs); if (!tx.IsNamecoin ()) return; BOOST_FOREACH (const CTxOut& txout, tx.vout) { const CNameScript nameOp(txout.scriptPubKey); if (nameOp.isNameOp () && nameOp.getNameOp () == OP_NAME_FIRSTUPDATE) { const valtype& name = nameOp.getOpName (); const NameTxMap::const_iterator mit = mapNameRegs.find (name); if (mit != mapNameRegs.end ()) { const CTxMemPool::txiter mit2 = pool.mapTx.find (mit->second); assert (mit2 != pool.mapTx.end ()); pool.removeRecursive (mit2->GetTx (), removed); } } }}
开发者ID:SeaWireNetworks,项目名称:namecoin-core,代码行数:25,
示例7: AssertLockHeldint CMerkleTx::SetMerkleBranch(const CBlock& block){ AssertLockHeld(cs_main); CBlock blockTmp; // Update the tx's hashBlock hashBlock = block.GetHash(); // Locate the transaction for (nIndex = 0; nIndex < (int)block.vtx.size(); nIndex++) if (block.vtx[nIndex] == *(CTransaction*)this) break; if (nIndex == (int)block.vtx.size()) { vMerkleBranch.clear(); nIndex = -1; LogPrintf("ERROR: SetMerkleBranch(): couldn't find tx in block/n"); return 0; } // Fill in merkle branch GetMerkleBranch(block, nIndex, vMerkleBranch); // Is the tx in a block that's in the main chain BlockMap::iterator mi = mapBlockIndex.find(hashBlock); if (mi == mapBlockIndex.end()) return 0; const CBlockIndex* pindex = (*mi).second; if (!pindex || !chainActive.Contains(pindex)) return 0; return chainActive.Height() - pindex->nHeight + 1;}
开发者ID:bankonme,项目名称:namecoin-core,代码行数:33,
示例8: AssertLockHeldbool CGovernanceTriggerManager::AddNewTrigger(uint256 nHash){ AssertLockHeld(governance.cs); // IF WE ALREADY HAVE THIS HASH, RETURN if (mapTrigger.count(nHash)) { LogPrint("gobject", "CGovernanceTriggerManager::AddNewTrigger -- Already have hash, nHash = %s, count = %d, size = %s/n", nHash.GetHex(), mapTrigger.count(nHash), mapTrigger.size()); return false; } CSuperblock_sptr pSuperblock; try { CSuperblock_sptr pSuperblockTmp(new CSuperblock(nHash)); pSuperblock = pSuperblockTmp; } catch (std::exception& e) { LogPrintf("CGovernanceTriggerManager::AddNewTrigger -- Error creating superblock: %s/n", e.what()); return false; } catch (...) { LogPrintf("CGovernanceTriggerManager::AddNewTrigger: Unknown Error creating superblock/n"); return false; } pSuperblock->SetStatus(SEEN_OBJECT_IS_VALID); mapTrigger.insert(std::make_pair(nHash, pSuperblock)); return true;}
开发者ID:dashpay,项目名称:dash,代码行数:29,
示例9: IsRBFOptInRBFTransactionState IsRBFOptIn(const CTransaction &tx, CTxMemPool &pool){ AssertLockHeld(pool.cs); CTxMemPool::setEntries setAncestors; // First check the transaction itself. if (SignalsOptInRBF(tx)) { return RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125; } // If this transaction is not in our mempool, then we can't be sure // we will know about all its inputs. if (!pool.exists(tx.GetHash())) { return RBF_TRANSACTIONSTATE_UNKNOWN; } // If all the inputs have nSequence >= maxint-1, it still might be // signaled for RBF if any unconfirmed parents have signaled. uint64_t noLimit = std::numeric_limits<uint64_t>::max(); std::string dummy; CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash()); pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false); BOOST_FOREACH(CTxMemPool::txiter it, setAncestors) { if (SignalsOptInRBF(it->GetTx())) { return RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125; } } return RBF_TRANSACTIONSTATE_FINAL;}
开发者ID:ctwiz,项目名称:stardust,代码行数:31,
示例10: AssertLockHeldbool CFeeBumper::commit(CWallet *pWallet){ AssertLockHeld(pWallet->cs_wallet); if (!vErrors.empty() || currentResult != BumpFeeResult::OK) { return false; } if (txid.IsNull() || !pWallet->mapWallet.count(txid)) { vErrors.push_back("Invalid or non-wallet transaction id"); currentResult = BumpFeeResult::MISC_ERROR; return false; } CWalletTx& oldWtx = pWallet->mapWallet[txid]; // make sure the transaction still has no descendants and hasen't been mined in the meantime if (!preconditionChecks(pWallet, oldWtx)) { return false; } CWalletTx wtxBumped(pWallet, MakeTransactionRef(std::move(mtx))); // commit/broadcast the tx CReserveKey reservekey(pWallet); wtxBumped.mapValue = oldWtx.mapValue; wtxBumped.mapValue["replaces_txid"] = oldWtx.GetHash().ToString(); wtxBumped.vOrderForm = oldWtx.vOrderForm; wtxBumped.strFromAccount = oldWtx.strFromAccount; wtxBumped.fTimeReceivedIsTxTime = true; wtxBumped.fFromMe = true; CValidationState state; if (!pWallet->CommitTransaction(wtxBumped, reservekey, g_connman.get(), state)) { // NOTE: CommitTransaction never returns false, so this should never happen. vErrors.push_back(strprintf("Error: The transaction was rejected! Reason given: %s", state.GetRejectReason())); return false; } bumpedTxid = wtxBumped.GetHash(); if (state.IsInvalid()) { // This can happen if the mempool rejected the transaction. Report // what happened in the "errors" response. vErrors.push_back(strprintf("Error: The transaction was rejected: %s", FormatStateMessage(state))); } // mark the original tx as bumped if (!pWallet->MarkReplaced(oldWtx.GetHash(), wtxBumped.GetHash())) { // TODO: see if JSON-RPC has a standard way of returning a response // along with an exception. It would be good to return information about // wtxBumped to the caller even if marking the original transaction // replaced does not succeed for some reason. vErrors.push_back("Error: Created new bumpfee transaction but could not mark the original transaction as replaced."); } return true;}
开发者ID:twkbtch,项目名称:bitcoin,代码行数:51,
示例11: AssertLockHeldvoid CDeterministicMNManager::CleanupCache(int nHeight){ AssertLockHeld(cs); std::vector<uint256> toDelete; for (const auto& p : mnListsCache) { if (p.second.GetHeight() + LISTS_CACHE_SIZE < nHeight) { toDelete.emplace_back(p.first); } } for (const auto& h : toDelete) { mnListsCache.erase(h); }}
开发者ID:dashpay,项目名称:dash,代码行数:14,
示例12: AssertLockHeldvoid CTxMemPool::removeConflicts(const CTransaction &tx){ // Remove transactions which depend on inputs of tx, recursively AssertLockHeld(cs); for (const CTxIn &txin : tx.vin) { auto it = mapNextTx.find(txin.prevout); if (it != mapNextTx.end()) { const CTransaction &txConflict = *it->second; if (txConflict != tx) { ClearPrioritisation(txConflict.GetHash()); removeRecursive(txConflict, MemPoolRemovalReason::CONFLICT); } } }}
开发者ID:DigiByte-Core,项目名称:digibyte,代码行数:16,
示例13: AssertLockHeldQString TransactionDesc::FormatTxStatus(const CWalletTx& wtx){ AssertLockHeld(cs_main); if (!wtx.IsFinal()) { if (wtx.nLockTime < LOCKTIME_THRESHOLD) return tr("Open for %n block(s)", "", nBestHeight - wtx.nLockTime); else return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.nLockTime)); } else { int nDepth = wtx.GetDepthInMainChain(); if (nDepth < 0) return tr("conflicted"); else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) return tr("%1/offline").arg(nDepth); else if (nDepth < 10) return tr("%1/unconfirmed").arg(nDepth); else return tr("%1 confirmations").arg(nDepth); };}
开发者ID:butterflypay,项目名称:butterflymaster,代码行数:22,
示例14: AssertLockHeldvoid CBasicKeyStore::ImplicitlyLearnRelatedKeyScripts(const CPubKey& pubkey){ AssertLockHeld(cs_KeyStore); CKeyID key_id = pubkey.GetID(); // We must actually know about this key already. assert(HaveKey(key_id) || mapWatchKeys.count(key_id)); // This adds the redeemscripts necessary to detect P2WPKH and P2SH-P2WPKH // outputs. Technically P2WPKH outputs don't have a redeemscript to be // spent. However, our current IsMine logic requires the corresponding // P2SH-P2WPKH redeemscript to be present in the wallet in order to accept // payment even to P2WPKH outputs. // Also note that having superfluous scripts in the keystore never hurts. // They're only used to guide recursion in signing and IsMine logic - if // a script is present but we can't do anything with it, it has no effect. // "Implicitly" refers to fact that scripts are derived automatically from // existing keys, and are present in memory, even without being explicitly // loaded (e.g. from a file). if (pubkey.IsCompressed()) { CScript script = GetScriptForDestination(WitnessV0KeyHash(key_id)); // This does not use AddCScript, as it may be overridden. CScriptID id(script); mapScripts[id] = std::move(script); }}
开发者ID:Chovanec,项目名称:bitcoin,代码行数:24,
注:本文中的AssertLockHeld函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ AssertMsgFailed函数代码示例 C++ AssertIsOnOwningThread函数代码示例 |