Skip to content

Commit f422093

Browse files
authored
Merge pull request duality-solutions#326 from duality-solutions/v2.4.17-Fixes
BDAP v2.4.17 Fixes
2 parents 13f070c + d6534f4 commit f422093

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

src/bdap/domainentry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ std::string CDomainEntry::GenerateOID() const
277277
{
278278
strHeight = std::to_string(nHeight);
279279
}
280-
if (!txHash.IsNull())
280+
if (!txHash.IsNull() && !IsInitialBlockDownload())
281281
{
282282
CTransactionRef txRef;
283283
uint256 hashBlock;

src/bdap/domainentrydb.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static bool CommonDataCheck(const CDomainEntry& entry, const vchCharString& vvch
360360
return true;
361361
}
362362

363-
bool CheckNewDomainEntryTxInputs(const CDomainEntry& entry, const CScript& scriptOp, const vchCharString& vvchOpParameters,
363+
bool CheckNewDomainEntryTxInputs(const CDomainEntry& entry, const CScript& scriptOp, const vchCharString& vvchOpParameters, const uint256& txHash,
364364
std::string& errorMessage, bool fJustCheck)
365365
{
366366
if (!CommonDataCheck(entry, vvchOpParameters, errorMessage))
@@ -372,8 +372,14 @@ bool CheckNewDomainEntryTxInputs(const CDomainEntry& entry, const CScript& scrip
372372
CDomainEntry getDomainEntry;
373373
if (GetDomainEntry(entry.vchFullObjectPath(), getDomainEntry))
374374
{
375-
errorMessage = "CheckNewDomainEntryTxInputs: - The entry " + getDomainEntry.GetFullObjectPath() + " already exists. Add new entry failed!";
376-
return error(errorMessage.c_str());
375+
if (entry.txHash != txHash) {
376+
errorMessage = "CheckNewDomainEntryTxInputs: - The entry " + getDomainEntry.GetFullObjectPath() + " already exists. Add new entry failed!";
377+
return error(errorMessage.c_str());
378+
}
379+
else {
380+
LogPrintf("%s -- Already have entry %s in local database. Skipping add entry step.\n", __func__, entry.GetFullObjectPath());
381+
return true;
382+
}
377383
}
378384

379385
if (!pDomainEntryDB)
@@ -449,7 +455,7 @@ bool CheckDeleteDomainEntryTxInputs(const CDomainEntry& entry, const CScript& sc
449455
return FlushLevelDB();
450456
}
451457

452-
bool CheckUpdateDomainEntryTxInputs(const CDomainEntry& entry, const CScript& scriptOp, const vchCharString& vvchOpParameters,
458+
bool CheckUpdateDomainEntryTxInputs(const CDomainEntry& entry, const CScript& scriptOp, const vchCharString& vvchOpParameters, const uint256& txHash,
453459
std::string& errorMessage, bool fJustCheck)
454460
{
455461
//if exists, check for owner's signature
@@ -462,8 +468,14 @@ bool CheckUpdateDomainEntryTxInputs(const CDomainEntry& entry, const CScript& sc
462468
CDomainEntry prevDomainEntry;
463469
if (!GetDomainEntry(entry.vchFullObjectPath(), prevDomainEntry))
464470
{
465-
errorMessage = "CheckUpdateDomainEntryTxInputs: - Can not find " + prevDomainEntry.GetFullObjectPath() + " entry; this update operation failed!";
466-
return error(errorMessage.c_str());
471+
if (entry.txHash != txHash) {
472+
errorMessage = "CheckUpdateDomainEntryTxInputs: - Can not find " + prevDomainEntry.GetFullObjectPath() + " entry; this update operation failed!";
473+
return error(errorMessage.c_str());
474+
}
475+
else {
476+
LogPrintf("%s -- Already have entry %s in local database. Skipping update entry step.\n", __func__, entry.GetFullObjectPath());
477+
return true;
478+
}
467479
}
468480

469481
CTxDestination bdapDest;
@@ -577,11 +589,11 @@ bool CheckDomainEntryTx(const CTransactionRef& tx, const CScript& scriptOp, cons
577589
entry.nHeight = nHeight;
578590
}
579591
if (strOperationType == "bdap_new_account")
580-
return CheckNewDomainEntryTxInputs(entry, scriptOp, vvchArgs, errorMessage, fJustCheck);
592+
return CheckNewDomainEntryTxInputs(entry, scriptOp, vvchArgs, tx->GetHash(), errorMessage, fJustCheck);
581593
else if (strOperationType == "bdap_delete_account")
582594
return CheckDeleteDomainEntryTxInputs(entry, scriptOp, vvchArgs, errorMessage, fJustCheck);
583595
else if (strOperationType == "bdap_update_account")
584-
return CheckUpdateDomainEntryTxInputs(entry, scriptOp, vvchArgs, errorMessage, fJustCheck);
596+
return CheckUpdateDomainEntryTxInputs(entry, scriptOp, vvchArgs, tx->GetHash(), errorMessage, fJustCheck);
585597
else if (strOperationType == "bdap_move_account")
586598
return CheckMoveDomainEntryTxInputs(entry, scriptOp, vvchArgs, errorMessage, fJustCheck);
587599
else if (strOperationType == "bdap_revoke_account")

src/bdap/domainentrydb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ bool GetDomainEntryPubKey(const std::vector<unsigned char>& vchPubKey, CDomainEn
4444
bool CheckDomainEntryDB();
4545
bool FlushLevelDB();
4646
void CleanupLevelDB(int& nRemoved);
47-
bool CheckNewDomainEntryTxInputs(const CDomainEntry& entry, const CScript& scriptOp, const vchCharString& vvchOpParameters,
47+
bool CheckNewDomainEntryTxInputs(const CDomainEntry& entry, const CScript& scriptOp, const vchCharString& vvchOpParameters, const uint256& txHash,
4848
std::string& errorMessage, bool fJustCheck);
4949
bool CheckDeleteDomainEntryTxInputs(const CTransaction& tx, const CDomainEntry& entry, const CScript& scriptOp, const vchCharString& vvchOpParameters,
5050
std::string& errorMessage, bool fJustCheck);
51-
bool CheckUpdateDomainEntryTxInputs(const CTransaction& tx, const CDomainEntry& entry, const CScript& scriptOp, const vchCharString& vvchOpParameters,
51+
bool CheckUpdateDomainEntryTxInputs(const CTransaction& tx, const CDomainEntry& entry, const CScript& scriptOp, const vchCharString& vvchOpParameters, const uint256& txHash,
5252
std::string& errorMessage, bool fJustCheck);
5353
bool CheckMoveDomainEntryTxInputs(const CTransaction& tx, const CDomainEntry& entry, const CScript& scriptOp, const vchCharString& vvchOpParameters,
5454
std::string& errorMessage, bool fJustCheck);

src/validation.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3706,7 +3706,10 @@ static bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state
37063706

37073707
// TODO : ENABLE BLOCK CACHE IN SPECIFIC CASES
37083708
if (hash != chainparams.GetConsensus().hashGenesisBlock) {
3709-
if (miSelf != mapBlockIndex.end()) {
3709+
if (miSelf != mapBlockIndex.end() && !miSelf->second) {
3710+
mapBlockIndex.erase(hash);
3711+
}
3712+
if (miSelf != mapBlockIndex.end() && miSelf->second) {
37103713
// Block header is already known.
37113714
pindex = miSelf->second;
37123715
if (ppindex)

0 commit comments

Comments
 (0)