Skip to content

Commit 5bfc4bc

Browse files
committed
refactor: use UniValue::VOBJ instead of setObject() when possible
1 parent 8b09188 commit 5bfc4bc

File tree

6 files changed

+9
-20
lines changed

6 files changed

+9
-20
lines changed

src/evo/deterministicmns.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ std::string CDeterministicMN::ToString() const
4444

4545
UniValue CDeterministicMN::ToJson() const
4646
{
47-
UniValue obj;
48-
obj.setObject();
49-
47+
UniValue obj(UniValue::VOBJ);
5048
obj.pushKV("type", std::string(GetMnType(nType).description));
5149
obj.pushKV("proTxHash", proTxHash.ToString());
5250
obj.pushKV("collateralHash", collateralOutpoint.hash.ToString());

src/evo/dmnstate.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ std::string CDeterministicMNState::ToString() const
3737

3838
UniValue CDeterministicMNState::ToJson(MnType nType) const
3939
{
40-
UniValue obj;
41-
obj.setObject();
40+
UniValue obj(UniValue::VOBJ);
4241
obj.pushKV("version", nVersion);
4342
obj.pushKV("service", addr.ToStringAddrPort());
4443
obj.pushKV("registeredHeight", nRegisteredHeight);
@@ -69,8 +68,7 @@ UniValue CDeterministicMNState::ToJson(MnType nType) const
6968

7069
UniValue CDeterministicMNStateDiff::ToJson(MnType nType) const
7170
{
72-
UniValue obj;
73-
obj.setObject();
71+
UniValue obj(UniValue::VOBJ);
7472
if (fields & Field_nVersion) {
7573
obj.pushKV("version", state.nVersion);
7674
}

src/evo/mnhftx.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ class MNHFTx
4949

5050
[[nodiscard]] UniValue ToJson() const
5151
{
52-
UniValue obj;
53-
obj.clear();
54-
obj.setObject();
52+
UniValue obj(UniValue::VOBJ);
5553
obj.pushKV("versionBit", (int)versionBit);
5654
obj.pushKV("quorumHash", quorumHash.ToString());
5755
obj.pushKV("sig", sig.ToString());

src/evo/simplifiedmns.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ std::string CSimplifiedMNListEntry::ToString() const
7272

7373
UniValue CSimplifiedMNListEntry::ToJson(bool extended) const
7474
{
75-
UniValue obj;
76-
obj.setObject();
75+
UniValue obj(UniValue::VOBJ);
7776
obj.pushKV("nVersion", nVersion);
7877
obj.pushKV("nType", ToUnderlying(nType));
7978
obj.pushKV("proRegTxHash", proRegTxHash.ToString());
@@ -239,8 +238,7 @@ bool CSimplifiedMNListDiff::BuildQuorumChainlockInfo(const llmq::CQuorumManager&
239238

240239
UniValue CSimplifiedMNListDiff::ToJson(bool extended) const
241240
{
242-
UniValue obj;
243-
obj.setObject();
241+
UniValue obj(UniValue::VOBJ);
244242

245243
obj.pushKV("nVersion", nVersion);
246244
obj.pushKV("baseBlockHash", baseBlockHash.ToString());

src/llmq/commitment.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ class CFinalCommitment
121121

122122
[[nodiscard]] UniValue ToJson() const
123123
{
124-
UniValue obj;
125-
obj.setObject();
124+
UniValue obj(UniValue::VOBJ);
126125
obj.pushKV("version", int{nVersion});
127126
obj.pushKV("llmqType", ToUnderlying(llmqType));
128127
obj.pushKV("quorumHash", quorumHash.ToString());

src/llmq/snapshot.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ static const std::string DB_QUORUM_SNAPSHOT = "llmq_S";
2323

2424
UniValue CQuorumSnapshot::ToJson() const
2525
{
26-
UniValue obj;
27-
obj.setObject();
26+
UniValue obj(UniValue::VOBJ);
2827
UniValue activeQ(UniValue::VARR);
2928
for (const bool h : activeQuorumMembers) {
3029
// cppcheck-suppress useStlAlgorithm
@@ -43,8 +42,7 @@ UniValue CQuorumSnapshot::ToJson() const
4342

4443
UniValue CQuorumRotationInfo::ToJson() const
4544
{
46-
UniValue obj;
47-
obj.setObject();
45+
UniValue obj(UniValue::VOBJ);
4846
obj.pushKV("extraShare", extraShare);
4947

5048
obj.pushKV("quorumSnapshotAtHMinusC", quorumSnapshotAtHMinusC.ToJson());

0 commit comments

Comments
 (0)