main.cpp from dev
This commit is contained in:
151
src/main.cpp
151
src/main.cpp
@@ -220,19 +220,19 @@ namespace {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct CBlockReject {
|
struct CBlockReject {
|
||||||
unsigned char chRejectCode;
|
unsigned char chRejectCode;
|
||||||
string strRejectReason;
|
string strRejectReason;
|
||||||
uint256 hashBlock;
|
uint256 hashBlock;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maintain validation-specific state about nodes, protected by cs_main, instead
|
* Maintain validation-specific state about nodes, protected by cs_main, instead
|
||||||
* by CNode's own locks. This simplifies asynchronous operation, where
|
* by CNode's own locks. This simplifies asynchronous operation, where
|
||||||
* processing of incoming data is done after the ProcessMessage call returns,
|
* processing of incoming data is done after the ProcessMessage call returns,
|
||||||
* and we're no longer holding the node's locks.
|
* and we're no longer holding the node's locks.
|
||||||
*/
|
*/
|
||||||
struct CNodeState {
|
struct CNodeState {
|
||||||
//! The peer's address
|
//! The peer's address
|
||||||
CService address;
|
CService address;
|
||||||
//! Whether we have a fully established connection.
|
//! Whether we have a fully established connection.
|
||||||
@@ -274,49 +274,49 @@ struct CNodeState {
|
|||||||
nBlocksInFlightValidHeaders = 0;
|
nBlocksInFlightValidHeaders = 0;
|
||||||
fPreferredDownload = false;
|
fPreferredDownload = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Map maintaining per-node state. Requires cs_main. */
|
/** Map maintaining per-node state. Requires cs_main. */
|
||||||
map<NodeId, CNodeState> mapNodeState;
|
map<NodeId, CNodeState> mapNodeState;
|
||||||
|
|
||||||
// Requires cs_main.
|
// Requires cs_main.
|
||||||
CNodeState *State(NodeId pnode) {
|
CNodeState *State(NodeId pnode) {
|
||||||
map<NodeId, CNodeState>::iterator it = mapNodeState.find(pnode);
|
map<NodeId, CNodeState>::iterator it = mapNodeState.find(pnode);
|
||||||
if (it == mapNodeState.end())
|
if (it == mapNodeState.end())
|
||||||
return NULL;
|
return NULL;
|
||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetHeight()
|
int GetHeight()
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
return chainActive.Height();
|
return chainActive.Height();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePreferredDownload(CNode* node, CNodeState* state)
|
void UpdatePreferredDownload(CNode* node, CNodeState* state)
|
||||||
{
|
{
|
||||||
nPreferredDownload -= state->fPreferredDownload;
|
nPreferredDownload -= state->fPreferredDownload;
|
||||||
|
|
||||||
// Whether this node should be marked as a preferred download node.
|
// Whether this node should be marked as a preferred download node.
|
||||||
state->fPreferredDownload = (!node->fInbound || node->fWhitelisted) && !node->fOneShot && !node->fClient;
|
state->fPreferredDownload = (!node->fInbound || node->fWhitelisted) && !node->fOneShot && !node->fClient;
|
||||||
|
|
||||||
nPreferredDownload += state->fPreferredDownload;
|
nPreferredDownload += state->fPreferredDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns time at which to timeout block request (nTime in microseconds)
|
// Returns time at which to timeout block request (nTime in microseconds)
|
||||||
int64_t GetBlockTimeout(int64_t nTime, int nValidatedQueuedBefore, const Consensus::Params &consensusParams)
|
int64_t GetBlockTimeout(int64_t nTime, int nValidatedQueuedBefore, const Consensus::Params &consensusParams)
|
||||||
{
|
{
|
||||||
return nTime + 500000 * consensusParams.nPowTargetSpacing * (4 + nValidatedQueuedBefore);
|
return nTime + 500000 * consensusParams.nPowTargetSpacing * (4 + nValidatedQueuedBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeNode(NodeId nodeid, const CNode *pnode) {
|
void InitializeNode(NodeId nodeid, const CNode *pnode) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CNodeState &state = mapNodeState.insert(std::make_pair(nodeid, CNodeState())).first->second;
|
CNodeState &state = mapNodeState.insert(std::make_pair(nodeid, CNodeState())).first->second;
|
||||||
state.name = pnode->addrName;
|
state.name = pnode->addrName;
|
||||||
state.address = pnode->addr;
|
state.address = pnode->addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinalizeNode(NodeId nodeid) {
|
void FinalizeNode(NodeId nodeid) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CNodeState *state = State(nodeid);
|
CNodeState *state = State(nodeid);
|
||||||
|
|
||||||
@@ -333,11 +333,11 @@ void FinalizeNode(NodeId nodeid) {
|
|||||||
nPreferredDownload -= state->fPreferredDownload;
|
nPreferredDownload -= state->fPreferredDownload;
|
||||||
|
|
||||||
mapNodeState.erase(nodeid);
|
mapNodeState.erase(nodeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age)
|
void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age)
|
||||||
{
|
{
|
||||||
/* int expired = pool.Expire(GetTime() - age);
|
/* int expired = pool.Expire(GetTime() - age);
|
||||||
if (expired != 0)
|
if (expired != 0)
|
||||||
LogPrint("mempool", "Expired %i transactions from the memory pool\n", expired);
|
LogPrint("mempool", "Expired %i transactions from the memory pool\n", expired);
|
||||||
|
|
||||||
@@ -345,11 +345,11 @@ void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age)
|
|||||||
pool.TrimToSize(limit, &vNoSpendsRemaining);
|
pool.TrimToSize(limit, &vNoSpendsRemaining);
|
||||||
BOOST_FOREACH(const uint256& removed, vNoSpendsRemaining)
|
BOOST_FOREACH(const uint256& removed, vNoSpendsRemaining)
|
||||||
pcoinsTip->Uncache(removed);*/
|
pcoinsTip->Uncache(removed);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requires cs_main.
|
// Requires cs_main.
|
||||||
// Returns a bool indicating whether we requested this block.
|
// Returns a bool indicating whether we requested this block.
|
||||||
bool MarkBlockAsReceived(const uint256& hash) {
|
bool MarkBlockAsReceived(const uint256& hash) {
|
||||||
map<uint256, pair<NodeId, list<QueuedBlock>::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash);
|
map<uint256, pair<NodeId, list<QueuedBlock>::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash);
|
||||||
if (itInFlight != mapBlocksInFlight.end()) {
|
if (itInFlight != mapBlocksInFlight.end()) {
|
||||||
CNodeState *state = State(itInFlight->second.first);
|
CNodeState *state = State(itInFlight->second.first);
|
||||||
@@ -362,10 +362,10 @@ bool MarkBlockAsReceived(const uint256& hash) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requires cs_main.
|
// Requires cs_main.
|
||||||
void MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Params& consensusParams, CBlockIndex *pindex = NULL) {
|
void MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Params& consensusParams, CBlockIndex *pindex = NULL) {
|
||||||
CNodeState *state = State(nodeid);
|
CNodeState *state = State(nodeid);
|
||||||
assert(state != NULL);
|
assert(state != NULL);
|
||||||
|
|
||||||
@@ -379,10 +379,10 @@ void MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Pa
|
|||||||
state->nBlocksInFlight++;
|
state->nBlocksInFlight++;
|
||||||
state->nBlocksInFlightValidHeaders += newentry.fValidatedHeaders;
|
state->nBlocksInFlightValidHeaders += newentry.fValidatedHeaders;
|
||||||
mapBlocksInFlight[hash] = std::make_pair(nodeid, it);
|
mapBlocksInFlight[hash] = std::make_pair(nodeid, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the last unknown block a peer advertized is not yet known. */
|
/** Check whether the last unknown block a peer advertized is not yet known. */
|
||||||
void ProcessBlockAvailability(NodeId nodeid) {
|
void ProcessBlockAvailability(NodeId nodeid) {
|
||||||
CNodeState *state = State(nodeid);
|
CNodeState *state = State(nodeid);
|
||||||
assert(state != NULL);
|
assert(state != NULL);
|
||||||
|
|
||||||
@@ -395,10 +395,10 @@ void ProcessBlockAvailability(NodeId nodeid) {
|
|||||||
state->hashLastUnknownBlock.SetNull();
|
state->hashLastUnknownBlock.SetNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update tracking information about which blocks a peer is assumed to have. */
|
/** Update tracking information about which blocks a peer is assumed to have. */
|
||||||
void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
|
void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
|
||||||
CNodeState *state = State(nodeid);
|
CNodeState *state = State(nodeid);
|
||||||
assert(state != NULL);
|
assert(state != NULL);
|
||||||
|
|
||||||
@@ -414,11 +414,11 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
|
|||||||
// An unknown block was announced; just assume that the latest one is the best one.
|
// An unknown block was announced; just assume that the latest one is the best one.
|
||||||
state->hashLastUnknownBlock = hash;
|
state->hashLastUnknownBlock = hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Find the last common ancestor two blocks have.
|
/** Find the last common ancestor two blocks have.
|
||||||
* Both pa and pb must be non-NULL. */
|
* Both pa and pb must be non-NULL. */
|
||||||
CBlockIndex* LastCommonAncestor(CBlockIndex* pa, CBlockIndex* pb) {
|
CBlockIndex* LastCommonAncestor(CBlockIndex* pa, CBlockIndex* pb) {
|
||||||
if (pa->nHeight > pb->nHeight) {
|
if (pa->nHeight > pb->nHeight) {
|
||||||
pa = pa->GetAncestor(pb->nHeight);
|
pa = pa->GetAncestor(pb->nHeight);
|
||||||
} else if (pb->nHeight > pa->nHeight) {
|
} else if (pb->nHeight > pa->nHeight) {
|
||||||
@@ -433,11 +433,11 @@ CBlockIndex* LastCommonAncestor(CBlockIndex* pa, CBlockIndex* pb) {
|
|||||||
// Eventually all chain branches meet at the genesis block.
|
// Eventually all chain branches meet at the genesis block.
|
||||||
assert(pa == pb);
|
assert(pa == pb);
|
||||||
return pa;
|
return pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update pindexLastCommonBlock and add not-in-flight missing successors to vBlocks, until it has
|
/** Update pindexLastCommonBlock and add not-in-flight missing successors to vBlocks, until it has
|
||||||
* at most count entries. */
|
* at most count entries. */
|
||||||
void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<CBlockIndex*>& vBlocks, NodeId& nodeStaller) {
|
void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<CBlockIndex*>& vBlocks, NodeId& nodeStaller) {
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -517,7 +517,7 @@ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<CBl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anon namespace
|
} // anon namespace
|
||||||
|
|
||||||
@@ -1552,7 +1552,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*char *komodo_getspendscript(uint256 hash,int32_t n)
|
/*char *komodo_getspendscript(uint256 hash,int32_t n)
|
||||||
{
|
{
|
||||||
CTransaction tx; uint256 hashBlock;
|
CTransaction tx; uint256 hashBlock;
|
||||||
if ( !GetTransaction(hash,tx,hashBlock,true) )
|
if ( !GetTransaction(hash,tx,hashBlock,true) )
|
||||||
{
|
{
|
||||||
@@ -1563,7 +1563,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
|
|||||||
return((char *)tx.vout[n].scriptPubKey.ToString().c_str());
|
return((char *)tx.vout[n].scriptPubKey.ToString().c_str());
|
||||||
else printf("getspendscript illegal n.%d\n",n);
|
else printf("getspendscript illegal n.%d\n",n);
|
||||||
return(0);
|
return(0);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -1699,7 +1699,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
|
|||||||
return(nSubsidy);
|
return(nSubsidy);
|
||||||
} else return(0);
|
} else return(0);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
// Mining slow start
|
// Mining slow start
|
||||||
// The subsidy is ramped up linearly, skipping the middle payout of
|
// The subsidy is ramped up linearly, skipping the middle payout of
|
||||||
// MAX_SUBSIDY/2 to keep the monetary curve consistent with no slow start.
|
// MAX_SUBSIDY/2 to keep the monetary curve consistent with no slow start.
|
||||||
@@ -1950,8 +1950,8 @@ int GetSpendHeight(const CCoinsViewCache& inputs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace Consensus {
|
namespace Consensus {
|
||||||
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, const Consensus::Params& consensusParams)
|
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, const Consensus::Params& consensusParams)
|
||||||
{
|
{
|
||||||
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
|
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
|
||||||
// for an attacker to attempt to split the network.
|
// for an attacker to attempt to split the network.
|
||||||
if (!inputs.HaveInputs(tx))
|
if (!inputs.HaveInputs(tx))
|
||||||
@@ -1998,7 +1998,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
|
|||||||
int64_t interest; int32_t txheight; uint32_t locktime;
|
int64_t interest; int32_t txheight; uint32_t locktime;
|
||||||
if ( (interest= komodo_accrued_interest(&txheight,&locktime,prevout.hash,prevout.n,0,coins->vout[prevout.n].nValue,(int32_t)nSpendHeight-1)) != 0 )
|
if ( (interest= komodo_accrued_interest(&txheight,&locktime,prevout.hash,prevout.n,0,coins->vout[prevout.n].nValue,(int32_t)nSpendHeight-1)) != 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.Tip()->nTime);
|
//fprintf(stderr,"checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.Tip()->nTime);
|
||||||
nValueIn += interest;
|
nValueIn += interest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2031,7 +2031,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
|
|||||||
return state.DoS(100, error("CheckInputs(): nFees out of range"),
|
return state.DoS(100, error("CheckInputs(): nFees out of range"),
|
||||||
REJECT_INVALID, "bad-txns-fee-outofrange");
|
REJECT_INVALID, "bad-txns-fee-outofrange");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}// namespace Consensus
|
}// namespace Consensus
|
||||||
|
|
||||||
bool ContextualCheckInputs(
|
bool ContextualCheckInputs(
|
||||||
@@ -2104,7 +2104,7 @@ bool ContextualCheckInputs(
|
|||||||
|
|
||||||
|
|
||||||
/*bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheStore, const Consensus::Params& consensusParams, std::vector<CScriptCheck> *pvChecks)
|
/*bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheStore, const Consensus::Params& consensusParams, std::vector<CScriptCheck> *pvChecks)
|
||||||
{
|
{
|
||||||
if (!NonContextualCheckInputs(tx, state, inputs, fScriptChecks, flags, cacheStore, consensusParams, pvChecks)) {
|
if (!NonContextualCheckInputs(tx, state, inputs, fScriptChecks, flags, cacheStore, consensusParams, pvChecks)) {
|
||||||
fprintf(stderr,"ContextualCheckInputs failure.0\n");
|
fprintf(stderr,"ContextualCheckInputs failure.0\n");
|
||||||
return false;
|
return false;
|
||||||
@@ -2139,12 +2139,12 @@ bool ContextualCheckInputs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart)
|
bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart)
|
||||||
{
|
{
|
||||||
// Open history file to append
|
// Open history file to append
|
||||||
CAutoFile fileout(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
|
CAutoFile fileout(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
|
||||||
if (fileout.IsNull())
|
if (fileout.IsNull())
|
||||||
@@ -2168,10 +2168,10 @@ bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint
|
|||||||
fileout << hasher.GetHash();
|
fileout << hasher.GetHash();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uint256& hashBlock)
|
bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uint256& hashBlock)
|
||||||
{
|
{
|
||||||
// Open history file to read
|
// Open history file to read
|
||||||
CAutoFile filein(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION);
|
CAutoFile filein(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION);
|
||||||
if (filein.IsNull())
|
if (filein.IsNull())
|
||||||
@@ -2195,11 +2195,11 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uin
|
|||||||
return error("%s: Checksum mismatch", __func__);
|
return error("%s: Checksum mismatch", __func__);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Abort with a message */
|
/** Abort with a message */
|
||||||
bool AbortNode(const std::string& strMessage, const std::string& userMessage="")
|
bool AbortNode(const std::string& strMessage, const std::string& userMessage="")
|
||||||
{
|
{
|
||||||
strMiscWarning = strMessage;
|
strMiscWarning = strMessage;
|
||||||
LogPrintf("*** %s\n", strMessage);
|
LogPrintf("*** %s\n", strMessage);
|
||||||
uiInterface.ThreadSafeMessageBox(
|
uiInterface.ThreadSafeMessageBox(
|
||||||
@@ -2207,13 +2207,13 @@ bool AbortNode(const std::string& strMessage, const std::string& userMessage="")
|
|||||||
"", CClientUIInterface::MSG_ERROR);
|
"", CClientUIInterface::MSG_ERROR);
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbortNode(CValidationState& state, const std::string& strMessage, const std::string& userMessage="")
|
bool AbortNode(CValidationState& state, const std::string& strMessage, const std::string& userMessage="")
|
||||||
{
|
{
|
||||||
AbortNode(strMessage, userMessage);
|
AbortNode(strMessage, userMessage);
|
||||||
return state.Error(strMessage);
|
return state.Error(strMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anon namespace
|
} // anon namespace
|
||||||
|
|
||||||
@@ -2528,7 +2528,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
if (nSigOps > MAX_BLOCK_SIGOPS)
|
if (nSigOps > MAX_BLOCK_SIGOPS)
|
||||||
return state.DoS(100, error("ConnectBlock(): too many sigops"),
|
return state.DoS(100, error("ConnectBlock(): too many sigops"),
|
||||||
REJECT_INVALID, "bad-blk-sigops");
|
REJECT_INVALID, "bad-blk-sigops");
|
||||||
//fprintf(stderr,"ht.%d vout0 t%u\n",pindex->nHeight,tx.nLockTime);
|
//fprintf(stderr,"ht.%d vout0 t%u\n",pindex->nHeight,tx.nLockTime);
|
||||||
if (!tx.IsCoinBase())
|
if (!tx.IsCoinBase())
|
||||||
{
|
{
|
||||||
if (!view.HaveInputs(tx))
|
if (!view.HaveInputs(tx))
|
||||||
@@ -3524,6 +3524,8 @@ int32_t komodo_reverify_blockcheck(CValidationState& state,int32_t height,CBlock
|
|||||||
{
|
{
|
||||||
static int32_t oneshot;
|
static int32_t oneshot;
|
||||||
CBlockIndex *tipindex; int32_t rewindtarget;
|
CBlockIndex *tipindex; int32_t rewindtarget;
|
||||||
|
if ( KOMODO_REWIND != 0 )
|
||||||
|
oneshot = KOMODO_REWIND;
|
||||||
if ( oneshot == 0 && IsInitialBlockDownload() == 0 && (tipindex= chainActive.Tip()) != 0 )
|
if ( oneshot == 0 && IsInitialBlockDownload() == 0 && (tipindex= chainActive.Tip()) != 0 )
|
||||||
{
|
{
|
||||||
// if 200 blocks behind longestchain and no blocks for 2 hours
|
// if 200 blocks behind longestchain and no blocks for 2 hours
|
||||||
@@ -3743,7 +3745,12 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
|||||||
if ( pindex != 0 && pindex->nStatus & BLOCK_FAILED_MASK )
|
if ( pindex != 0 && pindex->nStatus & BLOCK_FAILED_MASK )
|
||||||
{
|
{
|
||||||
komodo_reverify_blockcheck(state,pindex->nHeight,pindex);
|
komodo_reverify_blockcheck(state,pindex->nHeight,pindex);
|
||||||
|
if ( KOMODO_LONGESTCHAIN != 0 && pindex->nHeight > KOMODO_LONGESTCHAIN-100 )
|
||||||
return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate");
|
return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pindex->nStatus &= ~BLOCK_FAILED_MASK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( pindex != 0 && IsInitialBlockDownload() == 0 ) // jl777 debug test
|
if ( pindex != 0 && IsInitialBlockDownload() == 0 ) // jl777 debug test
|
||||||
{
|
{
|
||||||
@@ -6435,9 +6442,9 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CBlockFileInfo::ToString() const {
|
std::string CBlockFileInfo::ToString() const {
|
||||||
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast));
|
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user