Merge pull request #7 from jl777/dPoW

DPoW
This commit is contained in:
jl777
2016-09-21 16:05:13 -03:00
committed by GitHub
3 changed files with 14 additions and 4 deletions

View File

@@ -71,6 +71,7 @@ cp ~/.zcash-params/testnet3/z9* ~/.zcash-params
./zcutil/build.sh -j8 # -j8 uses 8 threads
Once things are setup, you can build komodod with make from komodo/src directory. Also the error: configure: error: libsnark include directory not found, might appear and it looks like it can be ignored.
Create ~/.komodo/komodo.conf:
@@ -85,7 +86,7 @@ addnode="78.47.196.146"
Start mining:
komodo/src/komodod -gen=1 -genproclimit=1
komodo/src/komodod -gen=1 -genproclimit=1 -addnode="78.47.196.146"
komodo/src/komodo-cli getinfo
```

View File

@@ -28,7 +28,9 @@ int32_t komodo_checkmsg(void *bitcoinpeer,uint8_t *data,int32_t datalen)
int32_t komodo_blockcheck(void *block)
{
//fprintf(stderr,"check block %p\n",block);
return(-1);
// 1 -> valid notary block
// -1 -> invalid, ie, prior to notarized block
return(0);
}
#endif

View File

@@ -1334,6 +1334,7 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::M
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
{
int32_t retval;
block.SetNull();
// Open history file to read
@@ -1350,12 +1351,14 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
}
// Check the header
if ( komodo_blockcheck((void *)&block) < 0 )
if ( (retval= komodo_blockcheck((void *)&block)) == 0 )
{
if (!(CheckEquihashSolution(&block, Params()) &&
CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())))
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
}
else if ( retval < 0 )
return(false);
return true;
}
@@ -2942,7 +2945,8 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW)
{
if ( komodo_blockcheck((void *)&block) < 0 )
int32_t retval;
if ( (retval= komodo_blockcheck((void *)&block)) == 0 )
{
// Check Equihash solution is valid
if (fCheckPOW && !CheckEquihashSolution(&block, Params()))
@@ -2954,6 +2958,9 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool f
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),
REJECT_INVALID, "high-hash");
}
else if ( retval < 0 ) // komodo rejects block, ie. prior to notarized blockhash
return(false);
// Check timestamp
if (block.GetBlockTime() > GetAdjustedTime() + 600)
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),