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

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

CC BY-SA 3.0
2017-10-12T05:43:34.023Z
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
CC BY-SA 3.0
2017-10-12T06:01:59.110Z
primitives/block.h
Pieter Wuille
CC BY-SA 3.0
2017-10-12T14:46:12.140Z
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
CC BY-SA 3.0
2017-10-12T05:34:37.797Z
2017-10-12T05:34:37.797Z
Pieter Wuille
<p>I'm looking for a better understanding of how the flow of the code works. I'm running <code>bitcoind -regtest</code> in one terminal window, and in the other I'm using <code>bitcoin-cli regtest generate</code> to create blocks. What I'm having trouble with is understanding exactly what is happening in the code when I'm creating blocks. </p>

<p>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.</p>

<bitcoin-core-development>
Development questions regarding debugging and control flow
doc_sportello
# Development questions regarding debugging and control flow

(Asked by: username_0 on 2017-10-12)

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.

**Tags:** bitcoin-core-development


---

## 1 answers

### Answer by username_1 on 2017-10-12. Score: 1

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.

> **Comments:**
> **username_0**: 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?  
> **username_1**: primitives/block.h  
> **username_0**: 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.  

---

