MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / MarkReserveKeysAsUsed

Method MarkReserveKeysAsUsed

src/wallet/wallet.cpp:3714–3736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3712}
3713
3714void CWallet::MarkReserveKeysAsUsed(int64_t keypool_id)
3715{
3716 AssertLockHeld(cs_wallet);
3717 bool internal = setInternalKeyPool.count(keypool_id);
3718 if (!internal) assert(setExternalKeyPool.count(keypool_id) || set_pre_split_keypool.count(keypool_id));
3719 std::set<int64_t> *setKeyPool = internal ? &setInternalKeyPool : (set_pre_split_keypool.empty() ? &setExternalKeyPool : &set_pre_split_keypool);
3720 auto it = setKeyPool->begin();
3721
3722 WalletBatch batch(*database);
3723 while (it != std::end(*setKeyPool)) {
3724 const int64_t& index = *(it);
3725 if (index > keypool_id) break; // set*KeyPool is ordered
3726
3727 CKeyPool keypool;
3728 if (batch.ReadPool(index, keypool)) { //TODO: This should be unnecessary
3729 m_pool_key_to_index.erase(keypool.vchPubKey.GetID());
3730 }
3731 LearnAllRelatedScripts(keypool.vchPubKey);
3732 batch.ErasePool(index);
3733 WalletLogPrintf("keypool index %d removed\n", index);
3734 it = setKeyPool->erase(it);
3735 }
3736}
3737
3738void CWallet::GetScriptForMining(std::shared_ptr<CReserveScript> &script)
3739{

Callers

nothing calls this directly

Calls 7

ReadPoolMethod · 0.80
GetIDMethod · 0.80
ErasePoolMethod · 0.80
countMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected