Skip to content

Commit

Permalink
Merge branch 'development' into unordered_map
Browse files Browse the repository at this point in the history
  • Loading branch information
denravonska committed Oct 24, 2017
2 parents eb79917 + 4755eee commit ee641e5
Show file tree
Hide file tree
Showing 22 changed files with 916 additions and 1,134 deletions.
1 change: 0 additions & 1 deletion src/bitcoinrpc.cpp
Expand Up @@ -240,7 +240,6 @@ static const CRPCCommand vRPCCommands[] =
{ "getnettotals", &getnettotals, true, true },
{ "getdifficulty", &getdifficulty, true, false },
{ "getinfo", &getinfo, true, false },
{ "getsubsidy", &getsubsidy, true, false },
{ "getmininginfo", &getmininginfo, true, false },
{ "getstakinginfo", &getmininginfo, true, false },
{ "getnewaddress", &getnewaddress, true, false },
Expand Down
1 change: 0 additions & 1 deletion src/bitcoinrpc.h
Expand Up @@ -151,7 +151,6 @@ extern json_spirit::Value importprivkey(const json_spirit::Array& params, bool f
extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value sendalert(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value addnode(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getsubsidy(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getmininginfo(const json_spirit::Array& params, bool fHelp);

extern json_spirit::Value getnettotals(const json_spirit::Array& params, bool fHelp);
Expand Down
4 changes: 0 additions & 4 deletions src/global_objects_noui.hpp
Expand Up @@ -14,8 +14,6 @@ extern bool bForceUpdate;
extern bool bCheckedForUpgrade;
extern bool bCheckedForUpgradeLive;
extern bool bGlobalcomInitialized;
extern bool bDoTally;
extern bool bTallyFinished;
extern bool bGridcoinGUILoaded;

struct StructCPID
Expand Down Expand Up @@ -149,8 +147,6 @@ extern std::map<std::string, StructCPIDCache> mvAppCache; //Contains cached bloc
//Global CPU Mining CPID:
extern MiningCPID GlobalCPUMiningCPID;

//Boinc Valid Projects
extern std::map<std::string, StructCPID> mvBoincProjects; // Contains all of the allowed boinc projects;
// Timers
extern std::map<std::string, int> mvTimers; // Contains event timers that reset after max ms duration iterator is exceeded

Expand Down
66 changes: 4 additions & 62 deletions src/init.cpp
Expand Up @@ -24,13 +24,12 @@ bool LoadAdminMessages(bool bFullTableScan,std::string& out_errors);

StructCPID GetStructCPID();
bool ComputeNeuralNetworkSupermajorityHashes();
void BusyWaitForTally();
void TallyNetworkAverages();
extern void ThreadAppInit2(void* parg);

void LoadCPIDsInBackground();
bool IsConfigFileEmpty();

std::string ToOfficialName(std::string proj);

#ifndef WIN32
#include <signal.h>
#endif
Expand All @@ -45,8 +44,6 @@ extern unsigned int nNodeLifespan;
extern unsigned int nDerivationMethodIndex;
extern unsigned int nMinerSleep;
extern bool fUseFastIndex;
void InitializeBoincProjects();


//////////////////////////////////////////////////////////////////////////////
//
Expand All @@ -72,58 +69,6 @@ void StartShutdown()
#endif
}

void InitializeBoincProjects()
{
//Initialize GlobalCPUMiningCPID
GlobalCPUMiningCPID.initialized = true;
GlobalCPUMiningCPID.cpid="";
GlobalCPUMiningCPID.cpidv2 = "";
GlobalCPUMiningCPID.projectname ="";
GlobalCPUMiningCPID.rac=0;
GlobalCPUMiningCPID.encboincpublickey = "";
GlobalCPUMiningCPID.boincruntimepublickey = "";
GlobalCPUMiningCPID.pobdifficulty = 0;
GlobalCPUMiningCPID.diffbytes = 0;
GlobalCPUMiningCPID.email = "";
GlobalCPUMiningCPID.RSAWeight = 0;

//Loop through projects saved in the Gridcoin Persisted Data System
std::string sType = "project";
for(map<string,string>::iterator ii=mvApplicationCache.begin(); ii!=mvApplicationCache.end(); ++ii)
{
std::string key_name = (*ii).first;
if (key_name.length() > sType.length())
{
if (key_name.substr(0,sType.length())==sType)
{
std::string key_value = mvApplicationCache[(*ii).first];
std::vector<std::string> vKey = split(key_name,";");
if (vKey.size() > 0)
{

std::string project_name = vKey[1];
printf("Proj %s ",project_name.c_str());
std::string project_value = key_value;
boost::to_lower(project_name);
std::string mainProject = ToOfficialName(project_name);
boost::to_lower(mainProject);
StructCPID structcpid = GetStructCPID();
mvBoincProjects.insert(map<string,StructCPID>::value_type(mainProject,structcpid));
structcpid = mvBoincProjects[mainProject];
structcpid.initialized = true;
structcpid.link = "http://";
structcpid.projectname = mainProject;
mvBoincProjects[mainProject] = structcpid;
WHITELISTED_PROJECTS++;

}
}
}
}

}


void Shutdown(void* parg)
{
static CCriticalSection cs_Shutdown;
Expand All @@ -147,7 +92,6 @@ void Shutdown(void* parg)
printf("gridcoinresearch exiting...\r\n");

fShutdown = true;
nTransactionsUpdated++;
bitdb.Flush(false);
StopNode();
bitdb.Flush(true);
Expand Down Expand Up @@ -1024,8 +968,6 @@ bool AppInit2(ThreadHandlerPtr threads)
LoadAdminMessages(true,sOut);
printf("Done loading Admin messages");

InitializeBoincProjects();
printf("Done loading boinc projects");
uiInterface.InitMessage(_("Compute Neural Network Hashes..."));
ComputeNeuralNetworkSupermajorityHashes();

Expand All @@ -1052,10 +994,10 @@ bool AppInit2(ThreadHandlerPtr threads)

uiInterface.InitMessage(_("Loading Network Averages..."));
if (fDebug3) printf("Loading network averages");
if (!threads->createThread(StartNode, NULL, "Start Thread"))
TallyNetworkAverages();

if (!threads->createThread(StartNode, NULL, "Start Thread"))
InitError(_("Error: could not start node"));
BusyWaitForTally();

if (fServer)
threads->createThread(ThreadRPCServer, NULL, "RPC Server Thread");
Expand Down
13 changes: 7 additions & 6 deletions src/kernel.cpp
Expand Up @@ -76,9 +76,10 @@ static bool SelectBlockFromCandidates(vector<pair<int64_t, uint256> >& vSortedBy
*pindexSelected = (const CBlockIndex*) 0;
for (auto const& item : vSortedByTimestamp)
{
if (!mapBlockIndex.count(item.second))
const auto mapItem = mapBlockIndex.find(item.second);
if (mapItem == mapBlockIndex.end())
return error("SelectBlockFromCandidates: failed to find block index for candidate block %s", item.second.ToString().c_str());
const CBlockIndex* pindex = mapBlockIndex[item.second];
const CBlockIndex* pindex = mapItem->second;
if (fSelected && pindex->GetBlockTime() > nSelectionIntervalStop)
break;
if (mapSelectedBlocks.count(pindex->GetBlockHash()) > 0)
Expand Down Expand Up @@ -165,8 +166,7 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeMod
pindex = pindex->pprev;
}
int nHeightFirstCandidate = pindex ? (pindex->nHeight + 1) : 0;
reverse(vSortedByTimestamp.begin(), vSortedByTimestamp.end());
sort(vSortedByTimestamp.begin(), vSortedByTimestamp.end());
std::sort(vSortedByTimestamp.begin(), vSortedByTimestamp.end());

// Select 64 blocks from candidate blocks to generate stake modifier
uint64_t nStakeModifierNew = 0;
Expand Down Expand Up @@ -225,9 +225,10 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeMod
static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake)
{
nStakeModifier = 0;
if (!mapBlockIndex.count(hashBlockFrom))
const auto mapItem = mapBlockIndex.find(hashBlockFrom);
if (mapItem == mapBlockIndex.end())
return error("GetKernelStakeModifier() : block not indexed");
const CBlockIndex* pindexFrom = mapBlockIndex[hashBlockFrom];
const CBlockIndex* pindexFrom = mapItem->second;
nStakeModifierHeight = pindexFrom->nHeight;
nStakeModifierTime = pindexFrom->GetBlockTime();
int64_t nStakeModifierSelectionInterval = GetStakeModifierSelectionInterval();
Expand Down

0 comments on commit ee641e5

Please sign in to comment.