Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant LoadAdminMessages() calls #1625

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extern void GridcoinServices();
extern bool IsContract(CBlockIndex* pIndex);
extern bool BlockNeedsChecked(int64_t BlockTime);
int64_t GetEarliestWalletTransaction();
bool MemorizeMessage(const CTransaction &tx, double dAmount, std::string sRecipient);
extern bool LoadAdminMessages(bool bFullTableScan,std::string& out_errors);
extern bool GetEarliestStakeTime(std::string grcaddress, std::string cpid);
extern double GetTotalBalance();
Expand Down Expand Up @@ -2630,19 +2631,6 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck, boo
pindex->nResearchSubsidy = claim.m_research_subsidy;
pindex->nInterestSubsidy = claim.m_block_subsidy;
pindex->nIsSuperBlock = claim.ContainsSuperblock() ? 1 : 0;

// Must scan transactions after CoinStake to know if this is a contract.
int iPos = 0;
pindex->nIsContract = 0;
for (auto const& tx : vtx)
{
if (tx.hashBoinc.length() > 3 && iPos > 0)
{
pindex->nIsContract = 1;
break;
}
iPos++;
}
}

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

// Load contracts:
auto tx_iter = vtx.begin();
++tx_iter; // skip the first transaction

for (auto end = vtx.end(); tx_iter != end; ++tx_iter) {
if (tx_iter->hashBoinc.length() > 3) {
pindex->nIsContract = 1;
MemorizeMessage(*tx_iter, 0, ""); // TODO: replace with contract handler
}
}

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

if (pindex->nHeight % 5 == 0 && pindex->nHeight > 100)
{
std::string errors1 = "";
LoadAdminMessages(false,errors1);
}

if (!OutOfSyncByAge())
{
fColdBoot = false;
Expand Down Expand Up @@ -3101,10 +3093,6 @@ bool ReorganizeChain(CTxDB& txdb, unsigned &cnt_dis, unsigned &cnt_con, CBlock &
nTimeBestReceived = GetAdjustedTime();
cnt_con++;

// Load recent contracts
std::string admin_messages;
LoadAdminMessages(false, admin_messages);

if (IsV9Enabled_Tally(nBestHeight) && NN::Tally::IsTrigger(nBestHeight)) {
NN::Tally::LegacyRecount(pindexBest);
}
Expand Down