Skip to content

Commit

Permalink
Merge pull request #18 from Kiirocoin/datamining
Browse files Browse the repository at this point in the history
Datamining
  • Loading branch information
kiirodev committed May 12, 2024
2 parents c342ea3 + e7fe974 commit 3567346
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 10 deletions.
26 changes: 18 additions & 8 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,19 @@ class CMainParams : public CChainParams {

consensus.nStartCollateralChange = 75000;

std::vector<FundRewardStructure> rewardStructures = { {INT_MAX, 10} }; // 10% dev/community fee forever
std::vector<FundRewardStructure> rewardStructures = { {165000, 10}, {INT_MAX, 9} }; // 9% dev/community fee forever
std::vector<FundRewardStructure> rewardStructuresDataMining = { {INT_MAX, 7} }; // 7% data mining fee forever
consensus.nDevelopmentFundPayment = FundPayment(rewardStructures, 30, "KWTco92wURX5Jwu3mMdWrs36j574meAvew");
consensus.nCommunityFundPayment = FundPayment(rewardStructures, 30,"KDW8CeScVpWFzekvZm4f37qs5GxByEGSKE");
consensus.nDataMiningFundPayment = FundPayment(rewardStructuresDataMining, 190000,"KVibEVgfWA8qtiwdNNfH9n7tW3uL1ZFcRj");

consensus.nCollaterals = CMasternodeCollaterals(
{ {75000, 1000 * COIN}, // Block 0 - 74999 Collateral 1000
{125000, 2500 * COIN}, // Block 75000 - 124999 Collateral 2500
{175000, 3000 * COIN}, // Block 125000 - 174999 Collateral 3000
{INT_MAX, 4000 * COIN} // Block 175000 - Infinity Collateral 4000
},
{ {INT_MAX, 60} }
{ {165000, 60},{INT_MAX, 50} }
);

consensus.nStartBlacklist = 29399;
Expand Down Expand Up @@ -517,16 +520,18 @@ class CTestNetParams : public CChainParams {

consensus.nStartCollateralChange = 50;

std::vector<FundRewardStructure> rewardStructures = { {INT_MAX, 10} }; // 10% dev/community fee forever
std::vector<FundRewardStructure> rewardStructures = { {250, 10}, {INT_MAX, 9} }; // 9% dev/community fee forever
std::vector<FundRewardStructure> rewardStructuresDataMining = { { INT_MAX, 7} }; // 7% data mining fee forever
consensus.nDevelopmentFundPayment = FundPayment(rewardStructures, 1, "TWDxLLKsFp6qcV1LL4U2uNmW4HwMcapmMU");
consensus.nCommunityFundPayment = FundPayment(rewardStructures, 1,"TCkC4uoErEyCB4MK3d6ouyJELoXnuyqe9L");
consensus.nDataMiningFundPayment = FundPayment(rewardStructuresDataMining, 250,"TCkC4uoErEyCB4MK3d6ouyJELoXnuyqe9L");
consensus.nCollaterals = CMasternodeCollaterals(
{ {250, 50 * COIN},
{450, 150 * COIN},
{650, 250 * COIN},
{INT_MAX, 400 * COIN}
},
{ {250, 60}, {INT_MAX, 62} }
{ {250, 60}, {INT_MAX, 50} }
);

consensus.nStartBlacklist = 0;
Expand Down Expand Up @@ -796,14 +801,17 @@ class CDevNetParams : public CChainParams {

consensus.nStartCollateralChange = 200;

std::vector<FundRewardStructure> rewardStructures = { {INT_MAX, 10} }; // 10% dev/community fee forever
std::vector<FundRewardStructure> rewardStructures = { {200, 10}, {INT_MAX, 9} }; // 9% dev/community fee forever
std::vector<FundRewardStructure> rewardStructuresDataMining = { {INT_MAX, 7} }; // 7% Data Mining fee forever

consensus.nDevelopmentFundPayment = FundPayment(rewardStructures, 30, "TepVKkmUo1N6sazuM2wWwV7aiG4m1BUShU");
consensus.nCommunityFundPayment = FundPayment(rewardStructures, 30,"TZpbhfvQE61USHsxd55XdPpWBqu3SXB1EP");
consensus.nDataMiningFundPayment = FundPayment(rewardStructuresDataMining, 200,"TZpbhfvQE61USHsxd55XdPpWBqu3SXB1EP");
consensus.nCollaterals = CMasternodeCollaterals(
{ {200, 1000 * COIN},
{INT_MAX, 5000 * COIN}
},
{ {200, 60}, {INT_MAX, 62} }
{ {200, 60}, {INT_MAX, 50} }
);

consensus.nStartBlacklist = 0;
Expand Down Expand Up @@ -1037,14 +1045,16 @@ class CRegTestParams : public CChainParams {

consensus.nStartCollateralChange = 200;

std::vector<FundRewardStructure> rewardStructures = { {INT_MAX, 10} }; // 10% dev/community fee forever
std::vector<FundRewardStructure> rewardStructures = { {200, 10}, {INT_MAX, 9} }; // 10% dev/community fee forever
std::vector<FundRewardStructure> rewardStructuresDataMining = { {INT_MAX, 7} }; // 7% Data Mining fee forever
consensus.nDevelopmentFundPayment = FundPayment(rewardStructures, 1, "TGEGf26GwyUBE2P2o2beBAfE9Y438dCp5t");
consensus.nCommunityFundPayment = FundPayment(rewardStructures, 1,"TJmPzeJF4DECrBwUftc265U7rTPxKmpa4F");
consensus.nDataMiningFundPayment = FundPayment(rewardStructuresDataMining, 200,"TZpbhfvQE61USHsxd55XdPpWBqu3SXB1EP");
consensus.nCollaterals = CMasternodeCollaterals(
{ {200, 1000 * COIN},
{INT_MAX, 5000 * COIN}
},
{ {200, 60}, {INT_MAX, 62} }
{ {200, 60}, {INT_MAX, 50} }
);

consensus.nMajorityEnforceBlockUpgrade = 750;
Expand Down
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ struct Params {

FundPayment nDevelopmentFundPayment;
FundPayment nCommunityFundPayment;
FundPayment nDataMiningFundPayment;
CMasternodeCollaterals nCollaterals;

int nStartDuplicationCheck;
Expand Down
2 changes: 1 addition & 1 deletion src/fund_payment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CAmount FundPayment::getFundPaymentAmount(int blockHeight, CAmount blockReward)
}
for(int i = 0; i < rewardStructures.size(); i++) {
FundRewardStructure rewardStructure = rewardStructures[i];
if(rewardStructure.blockHeight == INT_MAX || blockHeight <= rewardStructure.blockHeight) {
if(rewardStructure.blockHeight == INT_MAX || blockHeight < rewardStructure.blockHeight) {
return blockReward * rewardStructure.rewardPercentage / 100;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,9 @@ void BlockAssembler::FillFoundersReward(CMutableTransaction &coinbaseTx, bool fM

FundPayment communityFundPayment = params.nCommunityFundPayment;
communityFundPayment.FillFundPayment(coinbaseTx, nHeight, nAmount,pblock->txoutCommunity);

FundPayment dataMiningFundPayment = params.nDataMiningFundPayment;
dataMiningFundPayment.FillFundPayment(coinbaseTx, nHeight, nAmount,pblock->txoutDataMining);
}
else {
// Stage 2
Expand Down
2 changes: 2 additions & 0 deletions src/primitives/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class CBlock : public CBlockHeader
// memory only
mutable CTxOut txoutCommunity; // community payment
mutable CTxOut txoutDevelopment; // development payment
mutable CTxOut txoutDataMining; // data mining payment
mutable CTxOut txoutZnode; // znode payment
mutable std::vector<CTxOut> voutSuperblock; // superblock payment
mutable bool fChecked;
Expand Down Expand Up @@ -324,6 +325,7 @@ class CBlock : public CBlockHeader
vtx.clear();
txoutCommunity = CTxOut();
txoutDevelopment = CTxOut();
txoutDataMining = CTxOut();
txoutZnode = CTxOut();
voutSuperblock.clear();
fChecked = false;
Expand Down
43 changes: 42 additions & 1 deletion src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,8 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");

if (g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0)
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Kiirocoin is not connected!");
if(Params().NetworkIDString() == "main")
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Kiirocoin is not connected!");

if (IsInitialBlockDownload())
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Kiirocoin is downloading blocks...");
Expand Down Expand Up @@ -848,6 +849,46 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
result.push_back(Pair("znode_payments_started", true));
result.push_back(Pair("znode_payments_enforced", true));


UniValue communityObj(UniValue::VOBJ);
FundPayment communityFundPayment = Params().GetConsensus().nCommunityFundPayment;
if(pblock->txoutCommunity != CTxOut()) {
CTxDestination address;
ExtractDestination(pblock->txoutCommunity.scriptPubKey, address);
CBitcoinAddress address2(address);
communityObj.push_back(Pair("payee", address2.ToString().c_str()));
communityObj.push_back(Pair("script", HexStr(pblock->txoutCommunity.scriptPubKey.begin(), pblock->txoutCommunity.scriptPubKey.end())));
communityObj.push_back(Pair("amount", pblock->txoutCommunity.nValue));
}
result.push_back(Pair("community", communityObj));
result.push_back(Pair("community_payments_started", pindexPrev->nHeight + 1 >= communityFundPayment.getStartBlock()));

UniValue developmentObj(UniValue::VOBJ);
FundPayment developmentFundPayment = Params().GetConsensus().nCommunityFundPayment;
if(pblock->txoutDevelopment != CTxOut()) {
CTxDestination address;
ExtractDestination(pblock->txoutDevelopment.scriptPubKey, address);
CBitcoinAddress address2(address);
developmentObj.push_back(Pair("payee", address2.ToString().c_str()));
developmentObj.push_back(Pair("script", HexStr(pblock->txoutDevelopment.scriptPubKey.begin(), pblock->txoutDevelopment.scriptPubKey.end())));
developmentObj.push_back(Pair("amount", pblock->txoutDevelopment.nValue));
}
result.push_back(Pair("developer", developmentObj));
result.push_back(Pair("developer_payments_started", pindexPrev->nHeight + 1 >= communityFundPayment.getStartBlock()));

UniValue dataMiningtObj(UniValue::VOBJ);
FundPayment dataMiningFundPayment = Params().GetConsensus().nDataMiningFundPayment;
if(pblock->txoutDataMining != CTxOut()) {
CTxDestination address;
ExtractDestination(pblock->txoutDataMining.scriptPubKey, address);
CBitcoinAddress address2(address);
dataMiningtObj.push_back(Pair("payee", address2.ToString().c_str()));
dataMiningtObj.push_back(Pair("script", HexStr(pblock->txoutDataMining.scriptPubKey.begin(), pblock->txoutDataMining.scriptPubKey.end())));
dataMiningtObj.push_back(Pair("amount", pblock->txoutDataMining.nValue));
}
result.push_back(Pair("datamining", dataMiningtObj));
result.push_back(Pair("datamining_payments_started", pindexPrev->nHeight + 1 >= dataMiningFundPayment.getStartBlock()));

if (pindexPrev->nHeight+1 >= Params().GetConsensus().DIP0003Height) {
result.push_back(Pair("coinbase_payload", HexStr(pblock->vtx[0]->vExtraPayload)));
}
Expand Down
16 changes: 16 additions & 0 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,22 @@ UniValue stop(const JSONRPCRequest& jsonRequest)
return "Kiirocoin server stopping";
}

UniValue uptime(const JSONRPCRequest& jsonRequest)
{
if (jsonRequest.fHelp || jsonRequest.params.size() > 1)
throw std::runtime_error(
"uptime\n"
"\nReturns the total uptime of the server.\n"
"\nResult:\n"
"ttt (numeric) The number of seconds that the server has been running\n"
"\nExamples:\n"
+ HelpExampleCli("uptime", "")
+ HelpExampleRpc("uptime", "")
);

return GetTime() - GetStartupTime();
}

/**
* Call Table
*/
Expand Down

0 comments on commit 3567346

Please sign in to comment.