Author

Topic: Where exactly in the source is the proof of work implemented? (Read 582 times)

hero member
Activity: 690
Merit: 501
Sorry for my noobish question, but I have been perusing the bitcoin source code and I can not find where exactly the sha-256 pow is implemented. I can see where the hash is defined in src/hash.h, but I can't find where it's used. Thank you.

Is this what you're looking for?

main.cpp
Code:
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW)
{
    // Check proof of work matches claimed amount
    if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits))
        return state.DoS(50, error("CheckBlockHeader() : proof of work failed"),
                         REJECT_INVALID, "high-hash");

Thanks, I'll take a look at that. I'm also looking at source codes with other PoW algorithms, to see how exactly someone goes about implementing their own hash function.
legendary
Activity: 3416
Merit: 4658
Sorry for my noobish question, but I have been perusing the bitcoin source code and I can not find where exactly the sha-256 pow is implemented. I can see where the hash is defined in src/hash.h, but I can't find where it's used. Thank you.

Is this what you're looking for?

main.cpp
Code:
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW)
{
    // Check proof of work matches claimed amount
    if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits))
        return state.DoS(50, error("CheckBlockHeader() : proof of work failed"),
                         REJECT_INVALID, "high-hash");
hero member
Activity: 690
Merit: 501
Sorry for my noobish question, but I have been perusing the bitcoin source code and I can not find where exactly the sha-256 pow is implemented. I can see where the hash is defined in src/hash.h, but I can't find where it's used. Thank you.
Jump to: