As per my understanding of bitcoin codebase, the following events happen after we solve a proof of work.

  1. In miner.cpp, once the miner thread solves a new Proof-of-work (PoW), ProcessBlockFound basically notifies others via a signal BlockFound.
  2. BlockFound signal calls ResetRequestCount which basically resets the mpRequestCount in wallet.h via the validationInterface.h.
  3. (Missing Logic)
  4. A new NetMsgType::INV is issued from main.cpp in SendMessages/ProcessMessages to all peers.
  5. These messages are eventually dispatched to all peers via network socket logic net.cpp

I am missing the main piece of code logic between step2 and step4. Can any expert help me understand what background story is happening after step2?

1 Answer 1


If you read a few lines after the BlockFound signal, you'll see:

CValidationState state;
if (!ProcessNewBlock(state, chainparams, NULL, pblock, true, NULL))
    return error("BitcoinMiner: ProcessNewBlock, block not accepted");


This is where the processing actually starts. ProcessNewBlock is defined in main.cpp.

  • I think you got my question wrong. ProcessNewBlock basically sanity checks the block, stores to disk and activates the best chain again. My question is where is the logic which actually sends the Hash out to other nodes? The mining logic is in miner.cpp sending logic is in main.cpp. Somewhere I miss where it picks the information of new block mined and sends out 'Hey! I have a new one' or INV message
    – Prem Anand
    Jan 27, 2016 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.