mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Merge #8753: Locked memory manager
444c673bench: Add benchmark for lockedpool allocation/deallocation (Wladimir J. van der Laan)6567999rpc: Add `getmemoryinfo` call (Wladimir J. van der Laan)4536148support: Add LockedPool (Wladimir J. van der Laan)f4d1fc2wallet: Get rid of LockObject and UnlockObject calls in key.h (Wladimir J. van der Laan)999e4c9wallet: Change CCrypter to use vectors with secure allocator (Wladimir J. van der Laan)
This commit is contained in:
@@ -450,10 +450,53 @@ UniValue setmocktime(const JSONRPCRequest& request)
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
static UniValue RPCLockedMemoryInfo()
|
||||
{
|
||||
LockedPool::Stats stats = LockedPoolManager::Instance().stats();
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("used", uint64_t(stats.used)));
|
||||
obj.push_back(Pair("free", uint64_t(stats.free)));
|
||||
obj.push_back(Pair("total", uint64_t(stats.total)));
|
||||
obj.push_back(Pair("locked", uint64_t(stats.locked)));
|
||||
obj.push_back(Pair("chunks_used", uint64_t(stats.chunks_used)));
|
||||
obj.push_back(Pair("chunks_free", uint64_t(stats.chunks_free)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
UniValue getmemoryinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
/* Please, avoid using the word "pool" here in the RPC interface or help,
|
||||
* as users will undoubtedly confuse it with the other "memory pool"
|
||||
*/
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
"getmemoryinfo\n"
|
||||
"Returns an object containing information about memory usage.\n"
|
||||
"\nResult:\n"
|
||||
"{\n"
|
||||
" \"locked\": { (json object) Information about locked memory manager\n"
|
||||
" \"used\": xxxxx, (numeric) Number of bytes used\n"
|
||||
" \"free\": xxxxx, (numeric) Number of bytes available in current arenas\n"
|
||||
" \"total\": xxxxxxx, (numeric) Total number of bytes managed\n"
|
||||
" \"locked\": xxxxxx, (numeric) Amount of bytes that succeeded locking. If this number is smaller than total, locking pages failed at some point and key data could be swapped to disk.\n"
|
||||
" \"chunks_used\": xxxxx, (numeric) Number allocated chunks\n"
|
||||
" \"chunks_free\": xxxxx, (numeric) Number unused chunks\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getmemoryinfo", "")
|
||||
+ HelpExampleRpc("getmemoryinfo", "")
|
||||
);
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("locked", RPCLockedMemoryInfo()));
|
||||
return obj;
|
||||
}
|
||||
|
||||
static const CRPCCommand commands[] =
|
||||
{ // category name actor (function) okSafeMode
|
||||
// --------------------- ------------------------ ----------------------- ----------
|
||||
{ "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */
|
||||
{ "control", "getmemoryinfo", &getmemoryinfo, true },
|
||||
{ "util", "validateaddress", &validateaddress, true }, /* uses wallet if enabled */
|
||||
{ "util", "createmultisig", &createmultisig, true },
|
||||
{ "util", "verifymessage", &verifymessage, true },
|
||||
|
||||
Reference in New Issue
Block a user