re: #22100 (review)
Comparing to 4e11f88 (which I reviewed in #21206) what is the motivation to prefix with Cached
? Is it relevant for the caller that some caching is involved? Is it a way to remember that concurrent syncs can happen and so the return value can be out of date?
There should be no changes since #21206, but CachedTx
is in debit/credit/change function names when the functions take CWalletTx
arguments, since the point of CWalletTx
class is to encapsulate CTransaction
plus cached balance information. Functions named Tx
instead of CachedTx
just take plain CTransaction
arguments by comparison. And functions named Input
, Output
, or Script
take those things as arguments.
I think it makes calling code more readable if function names explicitly say what they compute values from and whether values may be stale due to caching. But this is just a naming convention I settled on because I didnt like the previous convention where there are so many slightly different functions all having the same name. There could be better approaches I didn’t think of though.
Re: concurrency, I think cs_wallet doesn’t really allow too much and there shouldn’t be caching problems related to that. Caching more affects state transitions when blocks are connected disconnected and transactions are abandoned or replaced or added or removed from the mempool.