Skip to content

Commit

Permalink
Merge pull request #236 from carsenk/v3.4
Browse files Browse the repository at this point in the history
v3.3.9.2 Mandatory
  • Loading branch information
metaspartan committed Aug 25, 2019
2 parents d47701a + b04f4b0 commit 452d07b
Show file tree
Hide file tree
Showing 21 changed files with 381 additions and 180 deletions.
2 changes: 1 addition & 1 deletion denarius-qt.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = Denarius
VERSION = 3.3.9.1
VERSION = 3.3.9.2
INCLUDEPATH += src src/json src/qt src/qt/plugins/mrichtexteditor
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
CONFIG += no_include_pwd
Expand Down
14 changes: 9 additions & 5 deletions src/bitcoinrpc.cpp
Expand Up @@ -265,6 +265,11 @@ static const CRPCCommand vRPCCommands[] =
{ "getblockcount", &getblockcount, true, false },
{ "getconnectioncount", &getconnectioncount, true, false },
{ "getpeerinfo", &getpeerinfo, true, false },
{ "getaddednodeinfo", &getaddednodeinfo, true, true },
{ "ping", &ping, true, true },
{ "getnettotals", &getnettotals, true, false },
{ "disconnectnode", &disconnectnode, true, false },
{ "getnetworkinfo", &getnetworkinfo, true, false },
{ "gethashespersec", &gethashespersec, true, false },
{ "addnode", &addnode, true, true },
{ "dumpbootstrap", &dumpbootstrap, false, false },
Expand Down Expand Up @@ -301,7 +306,7 @@ static const CRPCCommand vRPCCommands[] =
{ "addredeemscript", &addredeemscript, false, false },
{ "getrawmempool", &getrawmempool, true, false },
{ "getblock", &getblock, false, false },
{ "getblockheader", &getblockheader, false, false },
{ "getblockheader", &getblockheader, false, false },
{ "getblock_old", &getblock_old, false, false },
{ "getblockbynumber", &getblockbynumber, false, false },
{ "getblockhash", &getblockhash, false, false },
Expand Down Expand Up @@ -359,7 +364,6 @@ static const CRPCCommand vRPCCommands[] =

/* Fortunastake features */
{ "getpoolinfo", &getpoolinfo, true, false},
{ "spork", &spork, true, false},
{ "masternode", &masternode, true, false},
{ "fortunastake", &fortunastake, true, false},

Expand Down Expand Up @@ -1314,7 +1318,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
if (strMethod == "getbalance" && n > 1) ConvertTo<int64_t>(params[1]);
if (strMethod == "getbalance" && n > 2) ConvertTo<bool>(params[2]);
if (strMethod == "getblock" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblockheader" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblockheader" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblock_old" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblockbynumber" && n > 0) ConvertTo<int64_t>(params[0]);
if (strMethod == "getblockbynumber" && n > 1) ConvertTo<bool>(params[1]);
Expand Down Expand Up @@ -1365,8 +1369,8 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
if (strMethod == "sendanontoanon" && n > 2) ConvertTo<int64_t>(params[2]);
if (strMethod == "sendanontod" && n > 1) ConvertTo<double>(params[1]);
if (strMethod == "sendanontod" && n > 2) ConvertTo<int64_t>(params[2]);
if (strMethod == "estimateanonfee" && n > 0) ConvertTo<double>(params[0]);
if (strMethod == "estimateanonfee" && n > 1) ConvertTo<int64_t>(params[1]);
if (strMethod == "estimateanonfee" && n > 0) ConvertTo<double>(params[0]);
if (strMethod == "estimateanonfee" && n > 1) ConvertTo<int64_t>(params[1]);

if (strMethod == "getpoolinfo" && n > 0) ConvertTo<int64_t>(params[0]);

Expand Down
11 changes: 10 additions & 1 deletion src/bitcoinrpc.h
Expand Up @@ -50,10 +50,14 @@ enum RPCErrorCode
RPC_INVALID_PARAMETER = -8, // Invalid, missing or duplicate parameter
RPC_DATABASE_ERROR = -20, // Database error
RPC_DESERIALIZATION_ERROR = -22, // Error parsing or validating structure in raw format
RPC_SERVER_NOT_STARTED = -18, // RPC server was not started (StartRPCThreads() not called)

// P2P client errors
RPC_CLIENT_NOT_CONNECTED = -9, // Bitcoin is not connected
RPC_CLIENT_IN_INITIAL_DOWNLOAD = -10, // Still downloading initial blocks
RPC_CLIENT_NODE_ALREADY_ADDED = -23, // Node is already added
RPC_CLIENT_NODE_NOT_ADDED = -24, // Node has not been added before
RPC_CLIENT_NODE_NOT_CONNECTED = -29, // Node to disconnect not found in connected nodes

// Wallet errors
RPC_WALLET_ERROR = -4, // Unspecified problem with wallet (key not found etc.)
Expand Down Expand Up @@ -152,6 +156,12 @@ extern std::vector<unsigned char> ParseHexO(const json_spirit::Object& o, std::s
extern json_spirit::Value getconnectioncount(const json_spirit::Array& params, bool fHelp); // in rpcnet.cpp
extern json_spirit::Value getpeerinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value addnode(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value ping(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getnettotals(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getnetworkinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value disconnectnode(const json_spirit::Array& params, bool fHelp);

extern json_spirit::Value dumpwallet(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value importwallet(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value dumpprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
Expand Down Expand Up @@ -251,7 +261,6 @@ extern json_spirit::Value reloadanondata(const json_spirit::Array& params, bool
extern json_spirit::Value txnreport(const json_spirit::Array& params, bool fHelp);

//rpcfortuna.cpp
extern json_spirit::Value spork(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getpoolinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value masternode(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value fortunastake(const json_spirit::Array& params, bool fHelp);
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Expand Up @@ -10,7 +10,7 @@
#define CLIENT_VERSION_MAJOR 3
#define CLIENT_VERSION_MINOR 3
#define CLIENT_VERSION_REVISION 9
#define CLIENT_VERSION_BUILD 1
#define CLIENT_VERSION_BUILD 2

// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
Expand Down
4 changes: 2 additions & 2 deletions src/fortuna.cpp
Expand Up @@ -40,12 +40,12 @@ CActiveFortunastake activeFortunastake;
int RequestedFortunaStakeList = 0;

//MIN_MN_PROTO_VERSION
int MIN_MN_PROTO_VERSION = 31000;
int MIN_MN_PROTO_VERSION = 33900; // D v3.3.9.2 - Proto - 33900

/* *** BEGIN FORTUNA MAGIC **********
Copyright 2014, Darkcoin Developers
eduffield - evan@darkcoin.io
Copyright 2018, Denarius Developers
Copyright 2018-2019, Denarius Developers
carsenk - admin@denarius.io
enkayz - enkayz@denarius.io
*/
Expand Down
2 changes: 1 addition & 1 deletion src/fortuna.h
Expand Up @@ -224,7 +224,7 @@ class CFortunaSession
class CForTunaPool
{
public:
static const int PROTOCOL_VERSION = 31005; //31005, D v3.3
static const int PROTOCOL_VERSION = 33900; //33900, D v3.3.9.2

// clients entries
std::vector<CForTunaEntry> myEntries;
Expand Down
5 changes: 3 additions & 2 deletions src/fortunastake.cpp
Expand Up @@ -131,15 +131,16 @@ void ProcessMessageFortunastake(CNode* pfrom, std::string& strCommand, CDataStre
if((fTestNet && addr.GetPort() != 19999) || (!fTestNet && addr.GetPort() != 9999)) return;

//search existing fortunastake list, this is where we update existing fortunastakes with new dsee broadcasts
LOCK(cs_fortunastakes);
LOCK(cs_fortunastakes);
BOOST_FOREACH(CFortunaStake& mn, vecFortunastakes) {
if(mn.vin.prevout == vin.prevout) {
// count == -1 when it's a new entry
// e.g. We don't want the entry relayed/time updated when we're syncing the list
// mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below,
// after that they just need to match
if(count == -1 && mn.pubkey == pubkey && !mn.UpdatedWithin(FORTUNASTAKE_MIN_DSEE_SECONDS)){
mn.UpdateLastSeen(); // update last seen without the sigTime since it's a new entry
mn.UpdateLastSeen(sigTime); // Updated UpdateLastSeen with sigTime
//mn.UpdateLastSeen(); // update last seen without the sigTime since it's a new entry

if(mn.now < sigTime){ //take the newest entry
if (fDebugFS & fDebugNet) printf("dsee - Got updated entry for %s\n", addr.ToString().c_str());
Expand Down
6 changes: 3 additions & 3 deletions src/fortunastake.h
Expand Up @@ -203,7 +203,7 @@ class CFortunaStake

void UpdateLastSeen(int64_t override=0)
{
if (override == 0) {
if (override == 0 || override > GetAdjustedTime()) {
lastTimeSeen = GetAdjustedTime();
} else {
lastTimeSeen = override;
Expand Down Expand Up @@ -342,8 +342,8 @@ class CFortunastakePayments
public:

CFortunastakePayments() {
strMainPubKey = "04af2b6c63d5e5937266a4ce630ab6ced73a0f6a5ff5611ef9b5cfc4f9e264e4a8a4840ab4da4d3ded243ef9f80f114d335dad9a87a50431004b35c01b2c68ea49";
strTestPubKey = "0406d6c9580d20c4daaacbade0f5bbe4448c511c5860f6dc27a1bf2a8c043b2ad27f3831f8e24750488f0c715100cc5a5811ffd578029f3af62633d9e1c51be384";
strMainPubKey = "";
strTestPubKey = "";
enabled = false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Expand Up @@ -489,7 +489,7 @@ bool AppInit2()
// Fee-per-kilobyte amount considered the same as "free"
// Be careful setting this: if you set it to zero then
// a transaction spammer can cheaply fill blocks using
// 1-satoshi-fee transactions. It should be set above the real
// 1-denarii-fee transactions. It should be set above the real
// cost to you of processing a transaction.
if (mapArgs.count("-mintxfee"))
ParseMoney(mapArgs["-mintxfee"], nMinTxFee);
Expand Down
13 changes: 6 additions & 7 deletions src/main.cpp
Expand Up @@ -2641,12 +2641,12 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)
if (!fIsInitialDownload) {
if (!CheckFSPayment(pindex, vtx[1].vout[i].nValue, mn)) // if MN is being paid and it's bottom 50% ranked, don't let it be paid.
{
if (pindexBest->nHeight >= MN_ENFORCEMENT_ACTIVE_HEIGHT) {
return error("CheckBlock-POS() : Out-of-cycle fortunastake payment detected, rejecting block.");
if (pindexBest->nHeight >= MN_ENFORCEMENT_ACTIVE_HEIGHT) { //Update PoS FS Payments to not go out of sync
return error("CheckBlock-POS() : Out-of-cycle fortunastake payment detected, rejecting block.");
} else {
if (fDebug) printf("WARNING: This fortunastake payment is too aggressive and will not be accepted after block %d\n", MN_ENFORCEMENT_ACTIVE_HEIGHT);
if (fDebug) printf("CheckBlock-POS(): This fortunastake payment is too aggressive and will be accepted after block %d\n", MN_ENFORCEMENT_ACTIVE_HEIGHT);
}
break;
//break;
} else {
if (fDebug) printf("CheckBlock-POS() : Payment meets rate requirement: payee has earnt %s against average %s\n",FormatMoney(mn.payValue).c_str(),FormatMoney(nAverageFSIncome).c_str());
}
Expand Down Expand Up @@ -2769,8 +2769,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)
if (pindexBest->nHeight >= MN_ENFORCEMENT_ACTIVE_HEIGHT)
{
return error("CheckBlock-POW() : Fortunastake overpayment detected, rejecting block. rank:%d value:%s avg:%s payRate:%s",mn.nRank,FormatMoney(mn.payValue).c_str(),FormatMoney(nAverageFSIncome).c_str(),FormatMoney(mn.payRate).c_str());
} else
{
} else {
if (fDebug) printf("WARNING: This fortunastake payment is too aggressive and will not be accepted after block %d\n", MN_ENFORCEMENT_ACTIVE_HEIGHT);
}
} else {
Expand Down Expand Up @@ -3681,7 +3680,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)

//After block 1.5m, The Minimum FortunaStake Protocol Version is 31005
if(nBestHeight >= 1500000) {
MIN_MN_PROTO_VERSION = 31005;
MIN_MN_PROTO_VERSION = 33900;
}

// ppcoin: if responsible for sync-checkpoint send it
Expand Down
1 change: 1 addition & 0 deletions src/makefile.arm
Expand Up @@ -32,6 +32,7 @@ endif
LIBS += \
-Wl,-B$(LMODE) \
-l boost_system$(BOOST_LIB_SUFFIX) \
-l boost_chrono$(BOOST_LIB_SUFFIX) \
-l boost_filesystem$(BOOST_LIB_SUFFIX) \
-l boost_program_options$(BOOST_LIB_SUFFIX) \
-l boost_thread$(BOOST_LIB_SUFFIX) \
Expand Down
2 changes: 1 addition & 1 deletion src/miner.cpp
Expand Up @@ -193,7 +193,7 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake, int64_t* pFees)
// Fee-per-kilobyte amount considered the same as "free"
// Be careful setting this: if you set it to zero then
// a transaction spammer can cheaply fill blocks using
// 1-satoshi-fee transactions. It should be set above the real
// 1-denarii-fee transactions. It should be set above the real
// cost to you of processing a transaction.
int64_t nMinTxFee = MIN_TX_FEE;
if (mapArgs.count("-mintxfee"))
Expand Down
62 changes: 49 additions & 13 deletions src/net.cpp
Expand Up @@ -47,19 +47,14 @@ void ThreadDNSAddressSeed2(void* parg);
bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false);


struct LocalServiceInfo {
int nScore;
int nPort;
};

//
// Global state variables
//
bool fDiscover = true;
bool fUseUPnP = false;
uint64_t nLocalServices = NODE_NETWORK;
static CCriticalSection cs_mapLocalHost;
static map<CNetAddr, LocalServiceInfo> mapLocalHost;
CCriticalSection cs_mapLocalHost;
map<CNetAddr, LocalServiceInfo> mapLocalHost;
static bool vfReachable[NET_MAX] = {};
static bool vfLimited[NET_MAX] = {};
static CNode* pnodeLocalHost = NULL;
Expand Down Expand Up @@ -471,7 +466,7 @@ CNode* FindNode(const CNetAddr& ip)
return NULL;
}

CNode* FindNode(std::string addrName)
CNode* FindNode(const std::string& addrName)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
Expand Down Expand Up @@ -565,7 +560,7 @@ void CNode::CloseSocketDisconnect()
fDisconnect = true;
if (hSocket != INVALID_SOCKET)
{
printf("disconnecting node %s\n", addrName.c_str());
printf("Net() Disconnecting node %s\n", addrName.c_str());
closesocket(hSocket);
hSocket = INVALID_SOCKET;

Expand Down Expand Up @@ -621,6 +616,35 @@ bool CNode::IsBanned(CNetAddr ip)
return fResult;
}

bool CNode::Ban(const CNetAddr &addr) {
int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
{
LOCK(cs_setBanned);
if (setBanned[addr] < banTime)
setBanned[addr] = banTime;
}
return true;
}

//Whitelisted peers/nodes
//std::vector<CSubNet> CNode::vWhitelistedRange;
//CCriticalSection CNode::cs_vWhitelistedRange;
/*
bool CNode::IsWhitelistedRange(const CNetAddr &addr) {
LOCK(cs_vWhitelistedRange);
BOOST_FOREACH(const CSubNet& subnet, vWhitelistedRange) {
if (subnet.Match(addr))
return true;
}
return false;
}
void CNode::AddWhitelistedRange(const CSubNet &subnet) {
LOCK(cs_vWhitelistedRange);
vWhitelistedRange.push_back(subnet);
}
*/

bool CNode::Misbehaving(int howmuch)
{
if (addr.IsLocal())
Expand Down Expand Up @@ -663,6 +687,7 @@ void CNode::copyStats(CNodeStats &stats)
X(fInbound);
X(nStartingHeight);
X(nMisbehavior);
//X(fWhitelisted);

// It is common for nodes with good ping times to suddenly become lagged,
// due to a new block arriving or other large transfer.
Expand Down Expand Up @@ -1107,6 +1132,17 @@ void ThreadSocketHandler2(void* parg)
pnode->CloseSocketDisconnect();
}
}
else if (nBytes > 100000) // 100,000 Bytes
{
// error
int nErr = WSAGetLastError();
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
{
if (!pnode->fDisconnect)
printf("Closing socket, output too large %d\n", nErr);
pnode->CloseSocketDisconnect();
}
}
}
}
}
Expand Down Expand Up @@ -1785,12 +1821,12 @@ bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOu
//
if (fShutdown)
return false;
if (!strDest)
if (!strDest) {
if (IsLocal(addrConnect) ||
FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) ||
FindNode(addrConnect.ToStringIPPort().c_str()))
FindNode((CNetAddr) addrConnect) || CNode::IsBanned(addrConnect) ||
FindNode(addrConnect.ToStringIPPort()))
return false;
if (strDest && FindNode(strDest))
} else if (FindNode(strDest))
return false;

vnThreadsRunning[THREAD_OPENCONNECTIONS]--;
Expand Down

0 comments on commit 452d07b

Please sign in to comment.