Changeset View
Changeset View
Standalone View
Standalone View
src/script/sigcache.cpp
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | size_t nMaxCacheSize = | ||||
MAX_MAX_SIG_CACHE_SIZE) * | MAX_MAX_SIG_CACHE_SIZE) * | ||||
(size_t(1) << 20); | (size_t(1) << 20); | ||||
size_t nElems = signatureCache.setup_bytes(nMaxCacheSize); | size_t nElems = signatureCache.setup_bytes(nMaxCacheSize); | ||||
LogPrintf("Using %zu MiB out of %zu requested for signature cache, able to " | LogPrintf("Using %zu MiB out of %zu requested for signature cache, able to " | ||||
"store %zu elements\n", | "store %zu elements\n", | ||||
(nElems * sizeof(uint256)) >> 20, nMaxCacheSize >> 20, nElems); | (nElems * sizeof(uint256)) >> 20, nMaxCacheSize >> 20, nElems); | ||||
} | } | ||||
bool CachingTransactionSignatureChecker::IsCached( | |||||
const std::vector<uint8_t> &vchSig, const CPubKey &pubkey, | |||||
const uint256 &sighash) const { | |||||
uint256 entry; | |||||
signatureCache.ComputeEntry(entry, sighash, vchSig, pubkey); | |||||
return signatureCache.Get(entry, false); | |||||
} | |||||
bool CachingTransactionSignatureChecker::VerifySignature( | bool CachingTransactionSignatureChecker::VerifySignature( | ||||
const std::vector<uint8_t> &vchSig, const CPubKey &pubkey, | const std::vector<uint8_t> &vchSig, const CPubKey &pubkey, | ||||
const uint256 &sighash) const { | const uint256 &sighash) const { | ||||
uint256 entry; | uint256 entry; | ||||
signatureCache.ComputeEntry(entry, sighash, vchSig, pubkey); | signatureCache.ComputeEntry(entry, sighash, vchSig, pubkey); | ||||
deadalnix: This still needs to use the same code as above, or you are testing a piece of code while… | |||||
if (signatureCache.Get(entry, !store)) { | if (signatureCache.Get(entry, !store)) { | ||||
return true; | return true; | ||||
} | } | ||||
if (!TransactionSignatureChecker::VerifySignature(vchSig, pubkey, | if (!TransactionSignatureChecker::VerifySignature(vchSig, pubkey, | ||||
sighash)) { | sighash)) { | ||||
return false; | return false; | ||||
} | } | ||||
if (store) { | if (store) { | ||||
signatureCache.Set(entry); | signatureCache.Set(entry); | ||||
} | } | ||||
return true; | return true; | ||||
} | } |
This still needs to use the same code as above, or you are testing a piece of code while running another one, which is not very useful.
There are many option to achieve this. For isntance you can have a wrapper like
There are many options.