Skip to content

Commit

Permalink
Merge pull request dashpay#21 from iamunick/add-masternodelist-nextpa…
Browse files Browse the repository at this point in the history
…yment

Add masternodelist nextpayment
  • Loading branch information
barrystyle committed Oct 15, 2019
2 parents 1fa89cc + 6bafa45 commit 33cef2a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 34 deletions.
38 changes: 20 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ reset-files.bash
*.tar.gz

*.exe
src/dash
src/dashd
src/dash-cli
src/dash-tx
src/test/test_dash
src/qt/test/test_dash-qt
src/bench/bench_dash
src/pacglobal
src/pacglobal
src/pacglobal-cli
src/pacglobal-tx
src/test/test_pacglobal
src/qt/test/test_pacglobal-qt
src/bench/bench_pacglobal

# autoreconf
Makefile.in
Expand All @@ -35,8 +35,8 @@ config.log
config.status
configure
libtool
src/config/dash-config.h
src/config/dash-config.h.in
src/config/pacglobal-config.h
src/config/pacglobal-config.h.in
src/config/stamp-h1
share/setup.nsi
share/qt/Info.plist
Expand Down Expand Up @@ -81,13 +81,13 @@ libconftest.dylib*
# Compilation and Qt preprocessor part
*.qm
Makefile
dash-qt
Dash-Qt.app
pacglobal-qt
PACGlobal-Qt.app
!/depends/Makefile

# Unit-tests
Makefile.test
dash-qt_test
pacglobal-qt_test
src/test/buildenv.py

# Resources cpp
Expand All @@ -96,12 +96,14 @@ qrc_*.cpp
# Mac specific
.DS_Store
build
dist/
*.background.tiff

#lcov
*.gcno
*.gcda
/*.info
test_dash.coverage/
test_pacglobal.coverage/
total.coverage/
coverage_percent.txt

Expand All @@ -120,15 +122,15 @@ qa/cache/*
.autotools
/doc/doxygen/

libdashconsensus.pc
libpacglobalconsensus.pc
contrib/devtools/split-debug.sh
src/qt/dash-qt.bash
src/qt/pacglobal-qt.bash
qa/pull-tester/tests-config.sh

#development symlinks
dash-cli
dashd
dash-qt
pacglobal-cli
pacglobald
pacglobal-qt
make

/docker/bin
Expand Down
46 changes: 30 additions & 16 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,23 @@ void masternode_list_help()
"2. \"filter\" (string, optional) Filter results. Partial match by outpoint by default in all modes,\n"
" additional matches in some modes are also available\n"
"\nAvailable modes:\n"
" addr - Print ip address associated with a masternode (can be additionally filtered, partial match)\n"
" full - Print info in format 'status payee lastpaidtime lastpaidblock IP'\n"
" (can be additionally filtered, partial match)\n"
" info - Print info in format 'status payee IP'\n"
" (can be additionally filtered, partial match)\n"
" json - Print info in JSON format (can be additionally filtered, partial match)\n"
" lastpaidblock - Print the last block height a node was paid on the network\n"
" lastpaidtime - Print the last time a node was paid on the network\n"
" owneraddress - Print the masternode owner PACGlobal address\n"
" payee - Print the masternode payout PACGlobal address (can be additionally filtered,\n"
" partial match)\n"
" pubKeyOperator - Print the masternode operator public key\n"
" status - Print masternode status: ENABLED / POSE_BANNED\n"
" (can be additionally filtered, partial match)\n"
" votingaddress - Print the masternode voting PACGlobal address\n"
" addr - Print ip address associated with a masternode (can be additionally filtered, partial match)\n"
" full - Print info in format 'status payee lastpaidtime lastpaidblock nextpaymentblock IP'\n"
" (can be additionally filtered, partial match)\n"
" info - Print info in format 'status payee IP'\n"
" (can be additionally filtered, partial match)\n"
" json - Print info in JSON format (can be additionally filtered, partial match)\n"
" lastpaidblock - Print the last block height a node was paid on the network\n"
" nextpaymentblock - Print the projected block height a node will likely be paid on the network\n"
" (not guarenteed results as a POSE_BANNED state occuring later would prevent payment)\n"
" lastpaidtime - Print the last time a node was paid on the network\n"
" owneraddress - Print the masternode owner PACGlobal address\n"
" payee - Print the masternode payout PACGlobal address (can be additionally filtered,\n"
" partial match)\n"
" pubKeyOperator - Print the masternode operator public key\n"
" status - Print masternode status: ENABLED / POSE_BANNED\n"
" (can be additionally filtered, partial match)\n"
" votingaddress - Print the masternode voting PACGlobal address\n"
);
}

Expand Down Expand Up @@ -489,7 +491,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
if (request.fHelp || (
strMode != "addr" && strMode != "full" && strMode != "info" && strMode != "json" &&
strMode != "owneraddress" && strMode != "votingaddress" &&
strMode != "lastpaidtime" && strMode != "lastpaidblock" &&
strMode != "lastpaidtime" && strMode != "lastpaidblock" && strMode != "nextpaymentblock" &&
strMode != "payee" && strMode != "pubkeyoperator" &&
strMode != "status"))
{
Expand Down Expand Up @@ -518,6 +520,13 @@ UniValue masternodelist(const JSONRPCRequest& request)
return (int)pindex->nTime;
};

auto projectedPayees = mnList.GetProjectedMNPayees(mnList.GetValidMNsCount());
std::map<uint256, int> nextPayments;
for (size_t i = 0; i < projectedPayees.size(); i++) {
const auto& dmn = projectedPayees[i];
nextPayments.emplace(dmn->proTxHash, mnList.GetHeight() + (int)i + 1);
}

mnList.ForEachMN(false, [&](const CDeterministicMNCPtr& dmn) {
std::string strOutpoint = dmn->collateralOutpoint.ToStringShort();
Coin coin;
Expand Down Expand Up @@ -548,6 +557,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
payeeStr << " " << std::setw(10) <<
dmnToLastPaidTime(dmn) << " " << std::setw(6) <<
dmn->pdmnState->nLastPaidHeight << " " <<
(nextPayments.count(dmn->proTxHash) ? nextPayments[dmn->proTxHash] : -1) << " " <<
dmn->pdmnState->addr.ToString();
std::string strFull = streamFull.str();
if (strFilter !="" && strFull.find(strFilter) == std::string::npos &&
Expand Down Expand Up @@ -585,6 +595,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
objMN.push_back(Pair("status", dmnToStatus(dmn)));
objMN.push_back(Pair("lastpaidtime", dmnToLastPaidTime(dmn)));
objMN.push_back(Pair("lastpaidblock", dmn->pdmnState->nLastPaidHeight));
objMN.push_back(Pair("nextpaymentblock", nextPayments.count(dmn->proTxHash) ? nextPayments[dmn->proTxHash] : -1));
objMN.push_back(Pair("owneraddress", CBitcoinAddress(dmn->pdmnState->keyIDOwner).ToString()));
objMN.push_back(Pair("votingaddress", CBitcoinAddress(dmn->pdmnState->keyIDVoting).ToString()));
objMN.push_back(Pair("collateraladdress", collateralAddressStr));
Expand All @@ -593,6 +604,9 @@ UniValue masternodelist(const JSONRPCRequest& request)
} else if (strMode == "lastpaidblock") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return;
obj.push_back(Pair(strOutpoint, dmn->pdmnState->nLastPaidHeight));
} else if (strMode == "nextpaymentblock") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return;
obj.push_back(Pair(strOutpoint, nextPayments.count(dmn->proTxHash) ? nextPayments[dmn->proTxHash] : -1));
} else if (strMode == "lastpaidtime") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return;
obj.push_back(Pair(strOutpoint, dmnToLastPaidTime(dmn)));
Expand Down

0 comments on commit 33cef2a

Please sign in to comment.