|
|
@ -2227,7 +2227,7 @@ bool myAddtomempool(CTransaction &tx, CValidationState *pstate, bool fSkipExpiry |
|
|
|
bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock) |
|
|
|
{ |
|
|
|
memset(&hashBlock,0,sizeof(hashBlock)); |
|
|
|
if ( KOMODO_NSPV != 0 ) |
|
|
|
if ( KOMODO_NSPV > 0 ) |
|
|
|
{ |
|
|
|
int64_t rewardsum = 0; int32_t i,retval,txheight,currentheight,height=0,vout = 0; |
|
|
|
for (i=0; i<NSPV_U.U.numutxos; i++) |
|
|
@ -2281,7 +2281,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo |
|
|
|
bool NSPV_myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, int32_t &txheight, int32_t ¤theight) |
|
|
|
{ |
|
|
|
memset(&hashBlock,0,sizeof(hashBlock)); |
|
|
|
if ( KOMODO_NSPV != 0 ) |
|
|
|
if ( KOMODO_NSPV > 0 ) |
|
|
|
{ |
|
|
|
int64_t rewardsum = 0; int32_t i,retval,height=0,vout = 0; |
|
|
|
for (i=0; i<NSPV_U.U.numutxos; i++) |
|
|
@ -3427,7 +3427,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin |
|
|
|
{ |
|
|
|
CDiskBlockPos blockPos; |
|
|
|
const CChainParams& chainparams = Params(); |
|
|
|
if ( KOMODO_NSPV != 0 ) |
|
|
|
if ( KOMODO_NSPV > 0 ) |
|
|
|
return(true); |
|
|
|
if ( KOMODO_STOPAT != 0 && pindex->GetHeight() > KOMODO_STOPAT ) |
|
|
|
return(false); |
|
|
@ -4011,7 +4011,7 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) { |
|
|
|
|
|
|
|
void FlushStateToDisk() { |
|
|
|
CValidationState state; |
|
|
|
if ( KOMODO_NSPV == 0 ) |
|
|
|
if ( KOMODO_NSPV <= 0 ) |
|
|
|
FlushStateToDisk(state, FLUSH_STATE_ALWAYS); |
|
|
|
} |
|
|
|
|
|
|
@ -4162,7 +4162,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { |
|
|
|
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight(),true) != 0))) |
|
|
|
{ |
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
if ( !GetBoolArg("-disablewallet", false) && KOMODO_NSPV == 0 ) |
|
|
|
if ( !GetBoolArg("-disablewallet", false) && KOMODO_NSPV <= 0 ) |
|
|
|
pwalletMain->EraseFromWallet(tx.GetHash()); |
|
|
|
#endif |
|
|
|
} |
|
|
@ -4267,7 +4267,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * |
|
|
|
// Get the current commitment tree
|
|
|
|
SproutMerkleTree oldSproutTree; |
|
|
|
SaplingMerkleTree oldSaplingTree; |
|
|
|
if ( KOMODO_NSPV == 0 ) |
|
|
|
if ( KOMODO_NSPV <= 0 ) |
|
|
|
{ |
|
|
|
assert(pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), oldSproutTree)); |
|
|
|
assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), oldSaplingTree)); |
|
|
@ -4296,13 +4296,13 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * |
|
|
|
mapBlockSource.erase(pindexNew->GetBlockHash()); |
|
|
|
nTime3 = GetTimeMicros(); nTimeConnectTotal += nTime3 - nTime2; |
|
|
|
LogPrint("bench", " - Connect total: %.2fms [%.2fs]\n", (nTime3 - nTime2) * 0.001, nTimeConnectTotal * 0.000001); |
|
|
|
if ( KOMODO_NSPV == 0 ) |
|
|
|
if ( KOMODO_NSPV <= 0 ) |
|
|
|
assert(view.Flush()); |
|
|
|
} |
|
|
|
int64_t nTime4 = GetTimeMicros(); nTimeFlush += nTime4 - nTime3; |
|
|
|
LogPrint("bench", " - Flush: %.2fms [%.2fs]\n", (nTime4 - nTime3) * 0.001, nTimeFlush * 0.000001); |
|
|
|
// Write the chain state to disk, if necessary.
|
|
|
|
if ( KOMODO_NSPV == 0 ) |
|
|
|
if ( KOMODO_NSPV <= 0 ) |
|
|
|
{ |
|
|
|
if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED)) |
|
|
|
return false; |
|
|
@ -4318,7 +4318,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * |
|
|
|
|
|
|
|
// Update chainActive & related variables.
|
|
|
|
UpdateTip(pindexNew); |
|
|
|
if ( KOMODO_NSPV == 0 ) |
|
|
|
if ( KOMODO_NSPV <= 0 ) |
|
|
|
{ |
|
|
|
// Tell wallet about transactions that went from mempool
|
|
|
|
// to conflicted:
|
|
|
@ -4346,7 +4346,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * |
|
|
|
komodo_broadcast(pblock,8); |
|
|
|
else if ( ASSETCHAINS_SYMBOL[0] != 0 ) |
|
|
|
komodo_broadcast(pblock,4);*/ |
|
|
|
if ( KOMODO_NSPV == 0 ) |
|
|
|
if ( KOMODO_NSPV <= 0 ) |
|
|
|
{ |
|
|
|
if ( ASSETCHAINS_CBOPRET != 0 ) |
|
|
|
komodo_pricesupdate(pindexNew->GetHeight(),pblock); |
|
|
@ -6547,7 +6547,7 @@ bool InitBlockIndex() { |
|
|
|
if (!ActivateBestChain(true, state, &block)) |
|
|
|
return error("LoadBlockIndex(): genesis block cannot be activated"); |
|
|
|
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
|
|
|
|
if ( KOMODO_NSPV == 0 ) |
|
|
|
if ( KOMODO_NSPV <= 0 ) |
|
|
|
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS); |
|
|
|
else return(true); |
|
|
|
} catch (const std::runtime_error& e) { |
|
|
@ -7107,7 +7107,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
{ |
|
|
|
const CChainParams& chainparams = Params(); |
|
|
|
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id); |
|
|
|
//if ( KOMODO_NSPV != 0 )
|
|
|
|
//if ( KOMODO_NSPV > 0 )
|
|
|
|
//if ( strCommand != "version" && strCommand != "verack" )
|
|
|
|
// fprintf(stderr, "recv: %s (%u bytes) peer=%d\n", SanitizeString(strCommand).c_str(), (int32_t)vRecv.size(), (int32_t)pfrom->GetId());
|
|
|
|
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) |
|
|
@ -7282,7 +7282,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
{ |
|
|
|
pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); |
|
|
|
|
|
|
|
if ( KOMODO_NSPV != 0 ) |
|
|
|
if ( KOMODO_NSPV > 0 ) |
|
|
|
{ |
|
|
|
if ( (pfrom->nServices & NODE_NSPV) == 0 ) |
|
|
|
{ |
|
|
@ -7482,14 +7482,17 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
} |
|
|
|
else if (strCommand == "getnSPV") |
|
|
|
{ |
|
|
|
std::vector<uint8_t> payload; |
|
|
|
vRecv >> payload; |
|
|
|
komodo_nSPVreq(pfrom,payload); |
|
|
|
if ( KOMODO_NSPV == 0 ) |
|
|
|
{ |
|
|
|
std::vector<uint8_t> payload; |
|
|
|
vRecv >> payload; |
|
|
|
komodo_nSPVreq(pfrom,payload); |
|
|
|
} |
|
|
|
return(true); |
|
|
|
} |
|
|
|
else if (strCommand == "nSPV") |
|
|
|
{ |
|
|
|
if ( KOMODO_NSPV != 0 ) |
|
|
|
if ( KOMODO_NSPV > 0 ) |
|
|
|
{ |
|
|
|
std::vector<uint8_t> payload; |
|
|
|
vRecv >> payload; |
|
|
@ -7497,7 +7500,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
} |
|
|
|
return(true); |
|
|
|
} |
|
|
|
else if ( KOMODO_NSPV != 0 ) |
|
|
|
else if ( KOMODO_NSPV > 0 ) |
|
|
|
return(true); |
|
|
|
else if (strCommand == "inv") |
|
|
|
{ |
|
|
@ -8287,7 +8290,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) |
|
|
|
} |
|
|
|
state.fShouldBan = false; |
|
|
|
} |
|
|
|
if ( KOMODO_NSPV != 0 ) |
|
|
|
if ( KOMODO_NSPV > 0 ) |
|
|
|
{ |
|
|
|
komodo_nSPV(pto); |
|
|
|
return(true); |
|
|
@ -8498,7 +8501,7 @@ extern "C" const char* getDataDir() |
|
|
|
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight) |
|
|
|
{ |
|
|
|
CMutableTransaction mtx; |
|
|
|
if ( KOMODO_NSPV != 0 ) |
|
|
|
if ( KOMODO_NSPV > 0 ) |
|
|
|
{ |
|
|
|
mtx.fOverwintered = true; |
|
|
|
mtx.nExpiryHeight = 0; |
|
|
|