Skip to content

Commit d949fe6

Browse files
authored
Merge pull request #1793 from cyrossignol/cleanup-unused-functions
trivial: Cleanup unused legacy functions
2 parents 7efb336 + 254fbb8 commit d949fe6

File tree

9 files changed

+0
-148
lines changed

9 files changed

+0
-148
lines changed

src/contract/polls.cpp

-104
Original file line numberDiff line numberDiff line change
@@ -668,110 +668,6 @@ std::vector<polling::Poll> GetPolls(bool bDetail, bool includeExpired, std::stri
668668
return vPolls;
669669
}
670670

671-
UniValue GetJSONPollsReport(bool bDetail, std::string QueryByTitle, std::string& out_export, bool IncludeExpired)
672-
{
673-
//Title,ExpirationDate, Question, Answers, ShareType(1=Magnitude,2=Balance,3=Both)
674-
UniValue results(UniValue::VARR);
675-
UniValue entry(UniValue::VOBJ);
676-
entry.pushKV("Polls","Polls Report " + QueryByTitle);
677-
std::string rows;
678-
std::string row;
679-
double iPollNumber = 0;
680-
double total_participants = 0;
681-
double total_shares = 0;
682-
boost::to_lower(QueryByTitle);
683-
std::string sExport;
684-
std::string sExportRow;
685-
out_export.clear();
686-
687-
for(const auto& item : ReadCacheSection(Section::POLL))
688-
{
689-
const std::string& title = boost::to_lower_copy(item.first);
690-
const std::string& contract = item.second.value;
691-
std::string Expiration = ExtractXML(contract,"<EXPIRATION>","</EXPIRATION>");
692-
std::string Question = ExtractXML(contract,"<QUESTION>","</QUESTION>");
693-
std::string Answers = ExtractXML(contract,"<ANSWERS>","</ANSWERS>");
694-
std::string ShareType = ExtractXML(contract,"<SHARETYPE>","</SHARETYPE>");
695-
std::string sURL = ExtractXML(contract,"<URL>","</URL>");
696-
if (!PollExpired(title) || IncludeExpired)
697-
{
698-
if (QueryByTitle.empty() || QueryByTitle == title)
699-
{
700-
701-
if( (title.length()>128) &&
702-
(Expiration.length()>64) &&
703-
(Question.length()>4096) &&
704-
(Answers.length()>8192) &&
705-
(ShareType.length()>64) &&
706-
(sURL.length()>256) )
707-
continue;
708-
709-
const std::vector<std::string>& vAnswers = split(Answers.c_str(),";");
710-
711-
std::string::size_type longestanswer = 0;
712-
for (const std::string& answer : vAnswers)
713-
longestanswer = std::max( longestanswer, answer.length() );
714-
715-
if( longestanswer>128 )
716-
continue;
717-
718-
iPollNumber++;
719-
total_participants = 0;
720-
total_shares=0;
721-
std::string BestAnswer;
722-
double highest_share = 0;
723-
std::string ExpirationDate = TimestampToHRDate(RoundFromString(Expiration,0));
724-
std::string sShareType = GetShareType(RoundFromString(ShareType,0));
725-
std::string TitleNarr = "Poll #" + RoundToString((double)iPollNumber,0)
726-
+ " (" + ExpirationDate + " ) - " + sShareType;
727-
728-
entry.pushKV(TitleNarr,title);
729-
sExportRow = "<POLL><URL>" + sURL + "</URL><TITLE>" + title + "</TITLE><EXPIRATION>" + ExpirationDate + "</EXPIRATION><SHARETYPE>" + sShareType + "</SHARETYPE><QUESTION>" + Question + "</QUESTION><ANSWERS>"+Answers+"</ANSWERS>";
730-
731-
if (bDetail)
732-
{
733-
entry.pushKV("Question",Question);
734-
sExportRow += "<ARRAYANSWERS>";
735-
size_t i = 0;
736-
for (const std::string& answer : vAnswers)
737-
{
738-
double participants=0;
739-
double dShares = VotesCount(title, answer, RoundFromString(ShareType,0),participants);
740-
if (dShares > highest_share)
741-
{
742-
highest_share = dShares;
743-
BestAnswer = answer;
744-
}
745-
746-
entry.pushKV("#" + ToString(++i) + " [" + RoundToString(participants,3) + "]. " + answer,dShares);
747-
total_participants += participants;
748-
total_shares += dShares;
749-
sExportRow += "<RESERVED></RESERVED><ANSWERNAME>" + answer + "</ANSWERNAME><PARTICIPANTS>" + RoundToString(participants,0) + "</PARTICIPANTS><SHARES>" + RoundToString(dShares,0) + "</SHARES>";
750-
}
751-
sExportRow += "</ARRAYANSWERS>";
752-
753-
//Totals:
754-
entry.pushKV("Participants",total_participants);
755-
entry.pushKV("Total Shares",total_shares);
756-
if (total_participants < 3) BestAnswer = "";
757-
758-
entry.pushKV("Best Answer",BestAnswer);
759-
sExportRow += "<TOTALPARTICIPANTS>" + RoundToString(total_participants,0)
760-
+ "</TOTALPARTICIPANTS><TOTALSHARES>" + RoundToString(total_shares,0)
761-
+ "</TOTALSHARES><BESTANSWER>" + BestAnswer + "</BESTANSWER>";
762-
763-
}
764-
sExportRow += "</POLL>";
765-
sExport += sExportRow;
766-
}
767-
}
768-
}
769-
770-
results.push_back(entry);
771-
out_export = sExport;
772-
return results;
773-
}
774-
775671
UniValue GetJsonVoteDetailsReport(std::string pollname)
776672
{
777673
double total_shares = 0;

src/contract/polls.h

-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,5 @@ UniValue getjsonpoll(bool bDetail, bool includeExpired, std::string byTitle);
7070

7171
std::vector<polling::Poll> GetPolls(bool bDetail, bool includeExpired, std::string byTitle);
7272

73-
UniValue GetJSONPollsReport(bool bDetail, std::string QueryByTitle, std::string& out_export, bool IncludeExpired);
74-
7573
UniValue GetJsonVoteDetailsReport(std::string pollname);
7674

src/main.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ extern bool WalletOutOfSync();
3838
extern bool AskForOutstandingBlocks(uint256 hashStart);
3939
extern void ResetTimerMain(std::string timer_name);
4040
extern bool GridcoinServices();
41-
extern bool BlockNeedsChecked(int64_t BlockTime);
4241
int64_t GetEarliestWalletTransaction();
4342
extern bool GetEarliestStakeTime(std::string grcaddress, std::string cpid);
4443
extern double GetTotalBalance();
@@ -4228,20 +4227,6 @@ std::string ExtractXML(const std::string& XMLdata, const std::string& key, const
42284227
return XMLdata.substr(loc + (key.length()), loc_end - loc - (key.length()));
42294228
}
42304229

4231-
bool BlockNeedsChecked(int64_t BlockTime)
4232-
{
4233-
if (IsLockTimeWithin14days(BlockTime, GetAdjustedTime()))
4234-
{
4235-
if (fColdBoot) return false;
4236-
bool fOut = OutOfSyncByAge();
4237-
return !fOut;
4238-
}
4239-
else
4240-
{
4241-
return false;
4242-
}
4243-
}
4244-
42454230
bool GetEarliestStakeTime(std::string grcaddress, std::string cpid)
42464231
{
42474232
if (nBestHeight < 15)

src/main.h

-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ int64_t PreviousBlockAge();
280280
/** (try to) add transaction to memory pool **/
281281
bool AcceptToMemoryPool(CTxMemPool& pool, CTransaction &tx,
282282
bool* pfMissingInputs);
283-
bool GetWalletFile(CWallet* pwallet, std::string &strWalletFileOut);
284283
bool IsResearcher(const std::string& cpid);
285284

286285
bool SetBestChain(CTxDB& txdb, CBlock &blockNew, CBlockIndex* pindexNew);

src/test/util_tests.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -613,16 +613,6 @@ BOOST_AUTO_TEST_CASE(test_Capitalize)
613613
BOOST_CHECK_EQUAL(Capitalize("\x00\xfe\xff"), "\x00\xfe\xff");
614614
}
615615

616-
BOOST_AUTO_TEST_CASE(util_VerifyIsLockTimeWithin14days)
617-
{
618-
int64_t now = 1494060475;
619-
int64_t twoWeeksInSeconds = 1209600;
620-
int64_t time = now - twoWeeksInSeconds;
621-
622-
BOOST_CHECK(IsLockTimeWithin14days(time, now) == true);
623-
BOOST_CHECK(IsLockTimeWithin14days(time - 1, now) == false);
624-
}
625-
626616
BOOST_AUTO_TEST_CASE(util_IsLockTimeWithinMinutes)
627617
{
628618
int64_t now = 1494060475;

src/util/time.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ int64_t GetSystemTimeInSeconds()
6969
return GetTimeMicros()/1000000;
7070
}
7171

72-
bool IsLockTimeWithin14days(int64_t locktime, int64_t reference)
73-
{
74-
return IsLockTimeWithinMinutes(locktime, 14 * 24 * 60, reference);
75-
}
76-
7772
bool IsLockTimeWithinMinutes(int64_t locktime, int minutes, int64_t reference)
7873
{
7974
int64_t cutOff = reference - minutes * 60;

src/util/time.h

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ void SetMockTime(int64_t nMockTimeIn);
3636
/** For testing */
3737
int64_t GetMockTime();
3838

39-
bool IsLockTimeWithin14days(int64_t locktime, int64_t reference);
4039
bool IsLockTimeWithinMinutes(int64_t locktime, int minutes, int64_t reference);
4140

4241
void MilliSleep(int64_t n);

src/wallet/wallet.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -2136,14 +2136,6 @@ bool CWallet::SetDefaultKey(const CPubKey &vchPubKey)
21362136
return true;
21372137
}
21382138

2139-
bool GetWalletFile(CWallet* pwallet, string &strWalletFileOut)
2140-
{
2141-
if (!pwallet->fFileBacked)
2142-
return false;
2143-
strWalletFileOut = pwallet->strWalletFile;
2144-
return true;
2145-
}
2146-
21472139
//
21482140
// Mark old keypool keys as used,
21492141
// and generate all new keys

src/wallet/wallet.h

-2
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,5 @@ class CAccountingEntry
10761076
std::vector<char> _ssExtra;
10771077
};
10781078

1079-
bool GetWalletFile(CWallet* pwallet, std::string &strWalletFileOut);
1080-
10811079
MinedType GetGeneratedType(const uint256& tx, unsigned int vout);
10821080
#endif

0 commit comments

Comments
 (0)