3

I'm looking for a better understanding of how the flow of the code works. I'm running bitcoind -regtest in one terminal window, and in the other I'm using bitcoin-cli regtest generate to create blocks. What I'm having trouble with is understanding exactly what is happening in the code when I'm creating blocks.

My assumption was that blockencodings.cpp was used for that, so I put a print statement in it, but nothing ever prints to the console. Is there some issue with printing to the console when regtesting? Or am I not understanding the control flow here. Just looking for some help understanding either debugging, or the chain of functions when generating a block.

2

You want to look at miner.cpp, and perhaps at rpc/mining.cpp for the generate function that's exposed to RPC.

blockencodings.cpp is pretty much only used for the compact blocks P2P format specified by BIP152, and has nothing to do with normal block generation.

  • awesome, thanks for the tip. if I'm looking to try out a modification to the block header, is the relevant code in block.cpp and block.h? – doc_sportello Oct 12 '17 at 5:43
  • primitives/block.h – Pieter Wuille Oct 12 '17 at 6:01
  • Hmm for some reason the print statements in block.h aren't working. I put one into the CBlockHeader definition thinking it would trigger when I generated a block, but I can't see it in my bitcoind console. – doc_sportello Oct 12 '17 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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