Skip to content

Conversation

@promag
Copy link
Contributor

@promag promag commented Sep 23, 2018

This gives a small, but not relevant, performance improvement when calling importmulti RPC since MarkDirty is called only once.

Note that ImportScript is not atomic:

if (!pwallet->HaveWatchOnly(script) && !pwallet->AddWatchOnly(script, 0 /* nCreateTime */)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
}
if (isRedeemScript) {
const CScriptID id(script);
if (!pwallet->HaveCScript(id) && !pwallet->AddCScript(script)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding p2sh redeemScript to wallet");
}
ImportAddress(pwallet, id, strLabel);
} else {
CTxDestination destination;
if (ExtractDestination(script, destination)) {
pwallet->SetAddressBook(destination, strLabel, "receive");
}
}

ie something can fail after a successful AddWatchOnly, which could lead to invalid cached balances. That's why the MarkDirty call is done as early as possible.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 24, 2018

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@DrahtBot
Copy link
Contributor

Coverage Change (pull 14303) Reference (master)
Lines +0.0339 % 87.0361 %
Functions +0.1390 % 84.1130 %
Branches +0.0039 % 51.5451 %

@meshcollider
Copy link
Contributor

Concept ACK

@achow101
Copy link
Member

achow101 commented Oct 9, 2018

utACK 0a1bbf739890408c44dafd96f6643d86d54c2537

@meshcollider
Copy link
Contributor

meshcollider commented Oct 18, 2018

utACK 0a1bbf7
Needs rebase

@promag promag force-pushed the 2018-09-wallet-mark-dirty branch from 0a1bbf7 to 852f295 Compare October 20, 2018 10:04
@promag
Copy link
Contributor Author

promag commented Oct 20, 2018

Rebased.

@DrahtBot
Copy link
Contributor

Needs rebase

@promag promag closed this Oct 31, 2018
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants