Skip to content

Commit 4c40124

Browse files
authored
Merge pull request #1651 from cyrossignol/magnitude
Add precision to support magnitudes less than 1
2 parents 1756407 + b132c51 commit 4c40124

26 files changed

+1765
-558
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ GRIDCOIN_CORE_H = \
100100
neuralnet/accrual/research_age.h \
101101
neuralnet/claim.h \
102102
neuralnet/cpid.h \
103+
neuralnet/magnitude.h \
103104
neuralnet/project.h \
104105
neuralnet/quorum.h \
105106
neuralnet/researcher.h \

src/Makefile.test.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ GRIDCOIN_TESTS =\
4343
test/netbase_tests.cpp \
4444
test/neuralnet/claim_tests.cpp \
4545
test/neuralnet/cpid_tests.cpp \
46+
test/neuralnet/magnitude_tests.cpp \
4647
test/neuralnet/project_tests.cpp \
4748
test/neuralnet/researcher_tests.cpp \
4849
test/neuralnet/superblock_tests.cpp \

src/appcache.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "appcache.h"
2-
#include "main.h"
32
#include "util.h"
43

54
#include <boost/algorithm/string.hpp>

src/beacon.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ int64_t MaxBeaconAge()
7878
int64_t BeaconAgeAdvertiseThreshold()
7979
{
8080
// 5 months in seconds.
81-
return 3600 * 24 * 30 * 5;
81+
return 3600 * 24 * 30 * 5;
8282
}
8383

8484
void GetBeaconElements(const std::string& sBeacon, std::string& out_cpid, std::string& out_address, std::string& out_publickey)
@@ -101,7 +101,7 @@ std::string GetBeaconPublicKey(const std::string& cpid, bool bAdvertisingBeacon)
101101
std::string sBeacon = RetrieveBeaconValueWithMaxAge(cpid, iMaxSeconds);
102102
if (sBeacon.empty())
103103
return "";
104-
104+
105105
// Beacon data structure: CPID,hashRand,Address,beacon public key: base64 encoded
106106
std::string sContract = DecodeBase64(sBeacon);
107107
std::vector<std::string> vContract = split(sContract.c_str(),";");
@@ -244,14 +244,14 @@ bool VerifyBeaconContractTx(const CTransaction& tx)
244244
}
245245

246246
bool ImportBeaconKeysFromConfig(const std::string& cpid, CWallet* wallet)
247-
{
247+
{
248248
if(cpid.empty())
249249
return error("Empty CPID");
250250

251251
std::string strSecret = GetArgument("privatekey" + cpid + (fTestNet ? "testnet" : ""), "");
252252
if(strSecret.empty())
253253
return false;
254-
254+
255255
auto vecsecret = ParseHex(strSecret);
256256

257257
CKey key;
@@ -335,7 +335,7 @@ BeaconStatus GetBeaconStatus(std::string& sCPID)
335335
beacon_status.iBeaconTimestamp = BeaconTimeStamp(sCPID);
336336
beacon_status.timestamp = TimestampToHRDate(beacon_status.iBeaconTimestamp);
337337
beacon_status.hasBeacon = HasActiveBeacon(sCPID);
338-
beacon_status.dPriorSBMagnitude = NN::Tally::GetMagnitude(NN::MiningId::Parse(sCPID));
338+
beacon_status.dPriorSBMagnitude = NN::Tally::GetMagnitude(NN::MiningId::Parse(sCPID)).Floating();
339339
beacon_status.is_mine = (sCPID == NN::GetPrimaryCpid());
340340

341341
return beacon_status;

src/checkpoints.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#include <boost/range/adaptor/reversed.hpp>
77

88
#include "checkpoints.h"
9-
10-
#include "txdb.h"
11-
#include "main.h"
129
#include "uint256.h"
1310

1411

src/contract/polls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ std::pair<std::string, std::string> CreateVoteContract(std::string sTitle, std::
9999
const std::string primary_cpid = NN::GetPrimaryCpid();
100100

101101
std::string GRCAddress = DefaultWalletAddress();
102-
double dmag = NN::Tally::MyMagnitude();
102+
double dmag = NN::Tally::MyMagnitude().Floating();
103103
double poll_duration = PollDuration(sTitle) * 86400;
104104

105105
// Prevent Double Voting

src/db.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#define BITCOIN_DB_H
77

88
#include "fs.h"
9-
#include "main.h"
109
#include "streams.h"
10+
#include "sync.h"
11+
#include "version.h"
1112

1213
#include <map>
1314
#include <string>

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ void GetGlobalStatus()
570570

571571
try
572572
{
573-
double boincmagnitude = NN::Tally::MyMagnitude();
573+
double boincmagnitude = NN::Tally::MyMagnitude().Floating();
574574
uint64_t nWeight = 0;
575575
pwalletMain->GetStakeWeight(nWeight);
576576
nBoincUtilization = boincmagnitude; //Legacy Support for the about screen
@@ -2623,7 +2623,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)
26232623
{
26242624
// 6-4-2017 - Verify researchers stored block magnitude
26252625
// 2018 02 04 - Moved here for better effect.
2626-
double dNeuralNetworkMagnitude = NN::Tally::GetMagnitude(claim.m_mining_id);
2626+
double dNeuralNetworkMagnitude = NN::Tally::GetMagnitude(claim.m_mining_id).Floating();
26272627
if (claim.m_magnitude > (dNeuralNetworkMagnitude * 1.25)
26282628
&& (fTestNet || (!fTestNet && (pindex->nHeight-1) > 947000)))
26292629
{

src/miner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ bool CreateGridcoinReward(CBlock &blocknew, CBlockIndex* pindexPrev, int64_t &nR
10601060
}
10611061

10621062
if (const NN::CpidOption cpid = claim.m_mining_id.TryCpid()) {
1063-
claim.m_magnitude = NN::Tally::GetMagnitude(*cpid);
1063+
claim.m_magnitude = NN::Tally::GetMagnitude(*cpid).Floating();
10641064
}
10651065

10661066
LogPrintf(

0 commit comments

Comments
 (0)