<p>If you read a few lines after the BlockFound signal, you'll see:</p>

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

<p><a href="https://github.com/bitcoin/bitcoin/blob/v0.12.0rc2/src/miner.cpp#L373-L375" rel="nofollow">https://github.com/bitcoin/bitcoin/blob/v0.12.0rc2/src/miner.cpp#L373-L375</a></p>

<p>This is where the processing actually starts. <code>ProcessNewBlock</code> is defined in <code>main.cpp</code>.</p>

CC BY-SA 3.0
2016-01-27T02:59:07.840Z
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
CC BY-SA 3.0
2016-01-26T16:16:49.050Z
2016-01-26T16:16:49.050Z
morsecoder
<p>As per my understanding of bitcoin codebase, the following events happen after we solve a proof of work.</p>

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

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

<bitcoind><development><bitcoin-core-development><mining-theory>
How does PoW solved in miner.cpp gets transferred to main.cpp in source code?
Prem Anand
# How does PoW solved in miner.cpp gets transferred to main.cpp in source code?

(Asked by: username_0 on 2016-01-26)

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?

**Tags:** bitcoind, development, bitcoin-core-development, mining-theory


---

## 1 answers

### Answer by username_1 on 2016-01-26. Score: 2

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");

```

<https://github.com/bitcoin/bitcoin/blob/v0.12.0rc2/src/miner.cpp#L373-L375>

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

> **Comments:**
> **username_0**: 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  

---

