Skip to content

Commit a98e4d2

Browse files
authored
Merge pull request #1625 from cyrossignol/cleanup/load-admin-messages
Remove redundant LoadAdminMessages() calls
2 parents 264c8c6 + c4eb0a9 commit a98e4d2

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

src/main.cpp

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ extern void GridcoinServices();
4141
extern bool IsContract(CBlockIndex* pIndex);
4242
extern bool BlockNeedsChecked(int64_t BlockTime);
4343
int64_t GetEarliestWalletTransaction();
44+
bool MemorizeMessage(const CTransaction &tx, double dAmount, std::string sRecipient);
4445
extern bool LoadAdminMessages(bool bFullTableScan,std::string& out_errors);
4546
extern bool GetEarliestStakeTime(std::string grcaddress, std::string cpid);
4647
extern double GetTotalBalance();
@@ -2630,19 +2631,6 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck, boo
26302631
pindex->nResearchSubsidy = claim.m_research_subsidy;
26312632
pindex->nInterestSubsidy = claim.m_block_subsidy;
26322633
pindex->nIsSuperBlock = claim.ContainsSuperblock() ? 1 : 0;
2633-
2634-
// Must scan transactions after CoinStake to know if this is a contract.
2635-
int iPos = 0;
2636-
pindex->nIsContract = 0;
2637-
for (auto const& tx : vtx)
2638-
{
2639-
if (tx.hashBoinc.length() > 3 && iPos > 0)
2640-
{
2641-
pindex->nIsContract = 1;
2642-
break;
2643-
}
2644-
iPos++;
2645-
}
26462634
}
26472635

26482636
if (pindex->nHeight > nGrandfather && !fReorganizing)
@@ -2777,16 +2765,20 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck, boo
27772765
// Gridcoin: Track payments to CPID, and last block paid
27782766
NN::Tally::RecordRewardBlock(pindex);
27792767

2768+
// Load contracts:
2769+
auto tx_iter = vtx.begin();
2770+
++tx_iter; // skip the first transaction
2771+
2772+
for (auto end = vtx.end(); tx_iter != end; ++tx_iter) {
2773+
if (tx_iter->hashBoinc.length() > 3) {
2774+
pindex->nIsContract = 1;
2775+
MemorizeMessage(*tx_iter, 0, ""); // TODO: replace with contract handler
2776+
}
2777+
}
27802778

27812779
if (!txdb.WriteBlockIndex(CDiskBlockIndex(pindex)))
27822780
return error("Connect() : WriteBlockIndex for pindex failed");
27832781

2784-
if (pindex->nHeight % 5 == 0 && pindex->nHeight > 100)
2785-
{
2786-
std::string errors1 = "";
2787-
LoadAdminMessages(false,errors1);
2788-
}
2789-
27902782
if (!OutOfSyncByAge())
27912783
{
27922784
fColdBoot = false;
@@ -3101,10 +3093,6 @@ bool ReorganizeChain(CTxDB& txdb, unsigned &cnt_dis, unsigned &cnt_con, CBlock &
31013093
nTimeBestReceived = GetAdjustedTime();
31023094
cnt_con++;
31033095

3104-
// Load recent contracts
3105-
std::string admin_messages;
3106-
LoadAdminMessages(false, admin_messages);
3107-
31083096
if (IsV9Enabled_Tally(nBestHeight) && NN::Tally::IsTrigger(nBestHeight)) {
31093097
NN::Tally::LegacyRecount(pindexBest);
31103098
}

0 commit comments

Comments
 (0)