block check overrides
This commit is contained in:
@@ -25,5 +25,10 @@ int32_t komodo_checkmsg(void *bitcoinpeer,uint8_t *data,int32_t datalen)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t komodo_blockcheck(void *block)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"check block %p\n",block);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
35
src/main.cpp
35
src/main.cpp
@@ -3,7 +3,6 @@
|
|||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include "komodo.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include "sodium.h"
|
#include "sodium.h"
|
||||||
@@ -42,6 +41,8 @@ using namespace std;
|
|||||||
# error "Bitcoin cannot be compiled without assertions."
|
# error "Bitcoin cannot be compiled without assertions."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern "C" int32_t komodo_blockcheck(void *block);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global state
|
* Global state
|
||||||
*/
|
*/
|
||||||
@@ -1349,10 +1350,12 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check the header
|
// Check the header
|
||||||
if (!(CheckEquihashSolution(&block, Params()) &&
|
if ( komodo_blockcheck((void *)&block) < 0 )
|
||||||
CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())))
|
{
|
||||||
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
if (!(CheckEquihashSolution(&block, Params()) &&
|
||||||
|
CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())))
|
||||||
|
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2939,21 +2942,22 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
|
|||||||
|
|
||||||
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW)
|
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW)
|
||||||
{
|
{
|
||||||
// Check Equihash solution is valid
|
if ( komodo_blockcheck((void *)&block) < 0 )
|
||||||
if (fCheckPOW && !CheckEquihashSolution(&block, Params()))
|
{
|
||||||
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),
|
// Check Equihash solution is valid
|
||||||
REJECT_INVALID, "invalid-solution");
|
if (fCheckPOW && !CheckEquihashSolution(&block, Params()))
|
||||||
|
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),
|
||||||
// Check proof of work matches claimed amount
|
REJECT_INVALID, "invalid-solution");
|
||||||
if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus()))
|
|
||||||
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),
|
|
||||||
REJECT_INVALID, "high-hash");
|
|
||||||
|
|
||||||
|
// Check proof of work matches claimed amount
|
||||||
|
if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus()))
|
||||||
|
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),
|
||||||
|
REJECT_INVALID, "high-hash");
|
||||||
|
}
|
||||||
// Check timestamp
|
// Check timestamp
|
||||||
if (block.GetBlockTime() > GetAdjustedTime() + 600)
|
if (block.GetBlockTime() > GetAdjustedTime() + 600)
|
||||||
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),
|
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),
|
||||||
REJECT_INVALID, "time-too-new");
|
REJECT_INVALID, "time-too-new");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4096,6 +4100,7 @@ string GetWarnings(string strFor)
|
|||||||
//
|
//
|
||||||
// Messages
|
// Messages
|
||||||
//
|
//
|
||||||
|
#include "komodo.h"
|
||||||
|
|
||||||
|
|
||||||
bool static AlreadyHave(const CInv& inv)
|
bool static AlreadyHave(const CInv& inv)
|
||||||
|
|||||||
Reference in New Issue
Block a user