Skip to content

Commit 01d95a3

Browse files
committed
rpc, refactor: Add getblock_prevout
This change eliminates memory usage spike when compiling with Visual Studio 2022 (at least in Cirrus CI environment). Easy to review using `git diff --color-moved-ws=allow-indentation-change --color-moved=dimmed-zebra`
1 parent 5abbc9a commit 01d95a3

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/rpc/blockchain.cpp

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,29 @@ static CBlockUndo GetUndoChecked(BlockManager& blockman, const CBlockIndex* pblo
598598
return blockUndo;
599599
}
600600

601+
const RPCResult getblock_vin{
602+
RPCResult::Type::ARR, "vin", "",
603+
{
604+
{RPCResult::Type::OBJ, "", "",
605+
{
606+
{RPCResult::Type::ELISION, "", "The same output as verbosity = 2"},
607+
{RPCResult::Type::OBJ, "prevout", "(Only if undo information is available)",
608+
{
609+
{RPCResult::Type::BOOL, "generated", "Coinbase or not"},
610+
{RPCResult::Type::NUM, "height", "The height of the prevout"},
611+
{RPCResult::Type::NUM, "value", "The value in " + CURRENCY_UNIT},
612+
{RPCResult::Type::OBJ, "scriptPubKey", "",
613+
{
614+
{RPCResult::Type::STR, "asm", "The asm"},
615+
{RPCResult::Type::STR, "hex", "The hex"},
616+
{RPCResult::Type::STR, "address", /*optional=*/true, "The Bitcoin address (only if a well-defined address exists)"},
617+
{RPCResult::Type::STR, "type", "The type (one of: " + GetAllOutputTypes() + ")"},
618+
}},
619+
}},
620+
}},
621+
}
622+
};
623+
601624
static RPCHelpMan getblock()
602625
{
603626
return RPCHelpMan{"getblock",
@@ -657,26 +680,7 @@ static RPCHelpMan getblock()
657680
{
658681
{RPCResult::Type::OBJ, "", "",
659682
{
660-
{RPCResult::Type::ARR, "vin", "",
661-
{
662-
{RPCResult::Type::OBJ, "", "",
663-
{
664-
{RPCResult::Type::ELISION, "", "The same output as verbosity = 2"},
665-
{RPCResult::Type::OBJ, "prevout", "(Only if undo information is available)",
666-
{
667-
{RPCResult::Type::BOOL, "generated", "Coinbase or not"},
668-
{RPCResult::Type::NUM, "height", "The height of the prevout"},
669-
{RPCResult::Type::NUM, "value", "The value in " + CURRENCY_UNIT},
670-
{RPCResult::Type::OBJ, "scriptPubKey", "",
671-
{
672-
{RPCResult::Type::STR, "asm", "The asm"},
673-
{RPCResult::Type::STR, "hex", "The hex"},
674-
{RPCResult::Type::STR, "address", /*optional=*/true, "The Bitcoin address (only if a well-defined address exists)"},
675-
{RPCResult::Type::STR, "type", "The type (one of: " + GetAllOutputTypes() + ")"},
676-
}},
677-
}},
678-
}},
679-
}},
683+
getblock_vin,
680684
}},
681685
}},
682686
}},

0 commit comments

Comments
 (0)