Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Conflicts:
#	contrib/Installer/boinc/boinc/modPersistedDataSystem.vb
  • Loading branch information
gridcoin committed Jul 29, 2017
2 parents 070d7e3 + 9c182b7 commit 1d6e231
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 31 deletions.
18 changes: 12 additions & 6 deletions contrib/Installer/boinc/boinc/modPersistedDataSystem.vb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ Module modPersistedDataSystem
End If
Next
'sOut += "00000000000,275000;" 'This is a placeholder to be removed in Neural Network 2.0
'This is a placeholder to be removed in Neural Network 2.0.
'It is needed to bump the average magnitude above 70 to avoid having the superblock rejected.
'The CPID cannot be all 0 since it will be filtered out and the hashes of the ASCII and the
'binary superblock will diff. When the 70 average mag requirement has been lifted from the
'C++ code this placeholder can be removed.
' sOut += "00000000000000000000000000000001,32767;"
sOut += "</MAGNITUDES><QUOTES>"

surrogateRow.Database = "Prices"
Expand Down Expand Up @@ -522,7 +528,7 @@ Module modPersistedDataSystem
StoreHistoricalMagnitude()
bNeedsDgvRefreshed = True

End Sub
End Sub
Private Function GetMagByCPID(sCPID As String) As Row
Dim dr As New Row
dr.Database = "CPID"
Expand Down Expand Up @@ -809,8 +815,8 @@ Module modPersistedDataSystem
Dim lNoWitnesses As Long = 0

For Each cpid As Row In lstCPIDs
If cpid.Witnesses = 0 Then
lNoWitnesses += 1
If cpid.Witnesses = 0 Then
lNoWitnesses += 1
End If
Next
Return lNoWitnesses
Expand Down Expand Up @@ -1517,7 +1523,7 @@ Retry:

Return sPath + sFilename
End Function

Public Function GetEntryPrefix(dataRow As Row) As String
Dim sFilename As String = LCase(dataRow.Database) + "_" + LCase(dataRow.Table) + "_"
Return sFilename
Expand Down Expand Up @@ -1807,7 +1813,7 @@ Retry:
Return iMins
End Function



Public Function GetUnixFileAge(sPath As String) As Double
If File.Exists(sPath) = False Then Return 1000000
Expand Down Expand Up @@ -1837,7 +1843,7 @@ End Module

Public Class MyWebClient2
Inherits System.Net.WebClient
Private timeout As Long = 10000
Private timeout As Long = 5000
Protected Overrides Function GetWebRequest(ByVal uri As Uri) As System.Net.WebRequest
Dim w As System.Net.WebRequest = MyBase.GetWebRequest(uri)
w.Timeout = timeout
Expand Down
48 changes: 24 additions & 24 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ extern int64_t ComputeResearchAccrual(int64_t nTime, std::string cpid, std::stri
extern bool UpdateNeuralNetworkQuorumData();
bool AsyncNeuralRequest(std::string command_name,std::string cpid,int NodeLimit);
double qtExecuteGenericFunction(std::string function,std::string data);
extern std::string GetQuorumHash(std::string data);
extern std::string GetQuorumHash(const std::string& data);
extern bool FullSyncWithDPORNodes();

std::string qtExecuteDotNetStringFunction(std::string function, std::string data);
Expand Down Expand Up @@ -9276,30 +9276,30 @@ std::string CPIDHash(double dMagIn, std::string sCPID)
return sHash;
}

std::string GetQuorumHash(std::string data)
std::string GetQuorumHash(const std::string& data)
{
//Data includes the Magnitudes, and the Projects:
std::string sMags = ExtractXML(data,"<MAGNITUDES>","</MAGNITUDES>");
std::vector<std::string> vMags = split(sMags.c_str(),";");
std::string sHashIn = "";
for (unsigned int x = 0; x < vMags.size(); x++)
{
if (vMags[x].length() > 10)
{
std::vector<std::string> vRow = split(vMags[x].c_str(),",");
if (vRow.size() > 0)
{
if (vRow[0].length() > 5)
{
std::string sCPID = vRow[0];
double dMag = cdbl(vRow[1],0);
sHashIn += CPIDHash(dMag, sCPID) + "<COL>";
}
}
}
}
std::string sHash = RetrieveMd5(sHashIn);
return sHash;
//Data includes the Magnitudes, and the Projects:
std::string sMags = ExtractXML(data,"<MAGNITUDES>","</MAGNITUDES>");
std::vector<std::string> vMags = split(sMags.c_str(),";");
std::string sHashIn = "";
for (unsigned int x = 0; x < vMags.size(); x++)
{
std::vector<std::string> vRow = split(vMags[x].c_str(),",");

// Each row should consist of two fields, CPID and magnitude.
if(vRow.size() < 2)
continue;

// First row (CPID) must be exactly 32 bytes.
const std::string& sCPID = vRow[0];
if(sCPID.size() != 32)
continue;

double dMag = cdbl(vRow[1],0);
sHashIn += CPIDHash(dMag, sCPID) + "<COL>";
}

return RetrieveMd5(sHashIn);
}


Expand Down
2 changes: 1 addition & 1 deletion src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extern bool VerifyCPIDSignature(std::string sCPID, std::string sBlockHash, std::
bool NeedASuperblock();
bool VerifySuperblock(std::string superblock, int nHeight);
double ExtractMagnitudeFromExplainMagnitude();
std::string GetQuorumHash(std::string data);
std::string GetQuorumHash(const std::string& data);
double GetOutstandingAmountOwed(StructCPID &mag, std::string cpid, int64_t locktime, double& total_owed, double block_magnitude);
bool ComputeNeuralNetworkSupermajorityHashes();
bool UpdateNeuralNetworkQuorumData();
Expand Down
45 changes: 45 additions & 0 deletions src/test/gridcoin_tests.cpp

Large diffs are not rendered by default.

0 comments on commit 1d6e231

Please sign in to comment.