mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Few fixes related to SelectCoinsGroupedByAddresses (#3144)
* Fix cache usage in SelectCoinsGroupedByAddresses * Reset cache flags in SelectCoinsGroupedByAddresses when a block is (dis)connected * MakeCollateralAmounts should call SelectCoinsGroupedByAddresses with a limited number of inputs
This commit is contained in:
parent
1acd4742c4
commit
db7f471c7d
@ -1423,8 +1423,12 @@ bool CPrivateSendClientSession::MakeCollateralAmounts(CConnman& connman)
|
|||||||
{
|
{
|
||||||
if (!pwalletMain) return false;
|
if (!pwalletMain) return false;
|
||||||
|
|
||||||
|
// NOTE: We do not allow txes larger than 100kB, so we have to limit number of inputs here.
|
||||||
|
// We still want to consume a lot of inputs to avoid creating only smaller denoms though.
|
||||||
|
// Knowing that each CTxIn is at least 148b big, 400 inputs should take 400 x ~148b = ~60kB.
|
||||||
|
// This still leaves more than enough room for another data of typical MakeCollateralAmounts tx.
|
||||||
std::vector<CompactTallyItem> vecTally;
|
std::vector<CompactTallyItem> vecTally;
|
||||||
if (!pwalletMain->SelectCoinsGroupedByAddresses(vecTally, false, false)) {
|
if (!pwalletMain->SelectCoinsGroupedByAddresses(vecTally, false, false, true, 400)) {
|
||||||
LogPrint("privatesend", "CPrivateSendClientSession::MakeCollateralAmounts -- SelectCoinsGroupedByAddresses can't find any inputs!\n");
|
LogPrint("privatesend", "CPrivateSendClientSession::MakeCollateralAmounts -- SelectCoinsGroupedByAddresses can't find any inputs!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3002,8 +3002,9 @@ bool CWallet::SelectCoinsGroupedByAddresses(std::vector<CompactTallyItem>& vecTa
|
|||||||
|
|
||||||
isminefilter filter = ISMINE_SPENDABLE;
|
isminefilter filter = ISMINE_SPENDABLE;
|
||||||
|
|
||||||
// try to use cache for already confirmed anonymizable inputs, no cache should be used when the limit is specified
|
// Try using the cache for already confirmed anonymizable inputs.
|
||||||
if(nMaxOupointsPerAddress != -1 && fAnonymizable && fSkipUnconfirmed) {
|
// This should only be used if nMaxOupointsPerAddress was NOT specified.
|
||||||
|
if(nMaxOupointsPerAddress == -1 && fAnonymizable && fSkipUnconfirmed) {
|
||||||
if(fSkipDenominated && fAnonymizableTallyCachedNonDenom) {
|
if(fSkipDenominated && fAnonymizableTallyCachedNonDenom) {
|
||||||
vecTallyRet = vecAnonymizableTallyCachedNonDenom;
|
vecTallyRet = vecAnonymizableTallyCachedNonDenom;
|
||||||
LogPrint("selectcoins", "SelectCoinsGroupedByAddresses - using cache for non-denom inputs %d\n", vecTallyRet.size());
|
LogPrint("selectcoins", "SelectCoinsGroupedByAddresses - using cache for non-denom inputs %d\n", vecTallyRet.size());
|
||||||
@ -3075,8 +3076,9 @@ bool CWallet::SelectCoinsGroupedByAddresses(std::vector<CompactTallyItem>& vecTa
|
|||||||
vecTallyRet.push_back(item.second);
|
vecTallyRet.push_back(item.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cache already confirmed anonymizable entries for later use, no cache should be saved when the limit is specified
|
// Cache already confirmed anonymizable entries for later use.
|
||||||
if(nMaxOupointsPerAddress != -1 && fAnonymizable && fSkipUnconfirmed) {
|
// This should only be used if nMaxOupointsPerAddress was NOT specified.
|
||||||
|
if(nMaxOupointsPerAddress == -1 && fAnonymizable && fSkipUnconfirmed) {
|
||||||
if(fSkipDenominated) {
|
if(fSkipDenominated) {
|
||||||
vecAnonymizableTallyCachedNonDenom = vecTallyRet;
|
vecAnonymizableTallyCachedNonDenom = vecTallyRet;
|
||||||
fAnonymizableTallyCachedNonDenom = true;
|
fAnonymizableTallyCachedNonDenom = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user