Bitcoin Forum
June 28, 2024, 12:50:43 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Where exactly in the source is the proof of work implemented?  (Read 583 times)
cloudboy (OP)
Hero Member
*****
Offline Offline

Activity: 690
Merit: 501


View Profile
June 10, 2014, 08:53:50 PM
 #1

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.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3430
Merit: 4680



View Profile
June 10, 2014, 09:08:04 PM
 #2

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");
cloudboy (OP)
Hero Member
*****
Offline Offline

Activity: 690
Merit: 501


View Profile
June 10, 2014, 10:11:54 PM
 #3

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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!