From 482e550924e878c064559e65bf34251909caa7fe Mon Sep 17 00:00:00 2001 From: Bushstar Date: Wed, 6 Nov 2024 18:13:32 +0000 Subject: [PATCH] Overwrite mocknet MN --- src/dfi/masternodes.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/dfi/masternodes.cpp b/src/dfi/masternodes.cpp index 6aef72faf9..f86ef3abdf 100644 --- a/src/dfi/masternodes.cpp +++ b/src/dfi/masternodes.cpp @@ -300,6 +300,20 @@ std::optional> CMasternodesView::AmIOwner() const { } Res CMasternodesView::CreateMasternode(const uint256 &nodeId, const CMasternode &node, uint16_t timelock) { + auto writeNode = [&]() { + WriteBy(nodeId, node); + WriteBy(node.ownerAuthAddress, nodeId); + WriteBy(node.operatorAuthAddress, nodeId); + + if (timelock > 0) { + WriteBy(nodeId, timelock); + } + return Res::Ok(); + }; + + if (fMockNetwork) { + return writeNode(); + } // Check auth addresses and that there in no MN with such owner or operator if ((node.operatorType != 1 && node.operatorType != 4) || (node.ownerType != 1 && node.ownerType != 4) || node.ownerAuthAddress.IsNull() || node.operatorAuthAddress.IsNull() || GetMasternode(nodeId) || @@ -309,15 +323,7 @@ Res CMasternodesView::CreateMasternode(const uint256 &nodeId, const CMasternode "bad owner and|or operator address (should be P2PKH or P2WPKH only) or node with those addresses exists"); } - WriteBy(nodeId, node); - WriteBy(node.ownerAuthAddress, nodeId); - WriteBy(node.operatorAuthAddress, nodeId); - - if (timelock > 0) { - WriteBy(nodeId, timelock); - } - - return Res::Ok(); + return writeNode(); } Res CMasternodesView::ResignMasternode(CMasternode &node, const uint256 &nodeId, const uint256 &txid, int height) {