<blockquote>
  <p>I wanted to start mining bitcoin from the genesis block</p>
</blockquote>

<p>I'm pretty sure regtest will let you do that.</p>

<blockquote>
  <p>why wouldn't the peer just let me mine on my own chain and not broadcast my results to anybody?</p>
</blockquote>

<p>Because that would be pointless. You're not confirming transactions, and you won't get rewarded for your mining. Your chain will probably be overwritten the very next time you connect to the network.</p>

<blockquote>
  <p>Where in the v0.9.3 code does it essentially say "if not connected to peers, then don't allow generation"?</p>
</blockquote>

<p><a href="https://github.com/bitcoin/bitcoin/blob/0.9.3/src/miner.cpp#L512">Here:</a></p>

<pre><code>if (Params().NetworkID() != CChainParams::REGTEST) {
    // Busy-wait for the network to come online so we don't waste time mining
    // on an obsolete chain. In regtest mode we expect to fly solo.
    while (vNodes.empty())
        MilliSleep(1000);
}
</code></pre>

<p><a href="https://github.com/bitcoin/bitcoin/blob/ed98a6284b4c2f0be2e128dc7cf59d42eb49046c/src/chainparams.cpp#L171">It's here on versions after 0.9.3:</a></p>

<pre><code>fMiningRequiresPeers = true;
</code></pre>

<p><a href="https://github.com/bitcoin/bitcoin/commit/1712adbe0b084b6907b82db350a51ab44f8c3117">This commit</a>  changed it.</p>

CC BY-SA 3.0
2014-11-19T01:52:40.517Z
The `fMiningRequiresPeers = true` isn't on v0.9.3... ?
morsecoder
CC BY-SA 3.0
2014-11-19T01:56:17.620Z
@StephenM347 So it isn't. Fixed.
Nick ODell
CC BY-SA 3.0
2014-11-19T03:14:53.617Z
And it may be pointless, but my point was that (I thought) it wasn't harmful. It seems like from the comment in the code, though, that allowing mining while not connected might actually be harmful because you could waste time mining on an obsolete chain. This also shows me where to change if I want to temporarily disable this for debugging, so thanks!
morsecoder
CC BY-SA 3.0
2014-11-19T01:50:04.713Z
2014-11-19T02:00:59.130Z
2014-11-19T02:00:59.130Z
Nick ODell
<p>I wanted to start mining Bitcoin from the genesis block, so I cloned Bitcoin and removed the checkpoints. Then I compiled and started up the daemon. I wasn't connected to any other peers, however, so it wouldn't let me mine. I did <code>./bitcoin-cli setgenerate true</code> but <code>./bitcoin-cli getmininginfo</code> said I had <code>0 hashespersecond</code>. When I connected to just one other peer, though, (a peer which also didn't have the checkpoints or the block chain), I could start mining. </p>

<p>Theoretically, though, why wouldn't the peer just let me mine on my own chain and not broadcast my results to anybody? I know it's not really a peer-to-peer network in this case, but I don't see why it would harm anyone to allow mining like this. Where in the <code>v0.9.3</code> code does it essentially say "if not connected to peers, then don't allow generation"?</p>

<mining-technical-details><peers><checkpoints>
Why does the daemon require peers in order to start mining?
morsecoder
# Why does the daemon require peers in order to start mining?

(Asked by: username_0 on 2014-11-19)

I wanted to start mining Bitcoin from the genesis block, so I cloned Bitcoin and removed the checkpoints. Then I compiled and started up the daemon. I wasn't connected to any other peers, however, so it wouldn't let me mine. I did `./bitcoin-cli setgenerate true` but `./bitcoin-cli getmininginfo` said I had `0 hashespersecond`. When I connected to just one other peer, though, (a peer which also didn't have the checkpoints or the block chain), I could start mining.

Theoretically, though, why wouldn't the peer just let me mine on my own chain and not broadcast my results to anybody? I know it's not really a peer-to-peer network in this case, but I don't see why it would harm anyone to allow mining like this. Where in the `v0.9.3` code does it essentially say "if not connected to peers, then don't allow generation"?

**Tags:** mining-technical-details, peers, checkpoints


---

## 1 answers

### Answer by username_1 on 2014-11-19. Score: 7 | Accepted answer

> I wanted to start mining bitcoin from the genesis block

I'm pretty sure regtest will let you do that.

> why wouldn't the peer just let me mine on my own chain and not broadcast my results to anybody?

Because that would be pointless. You're not confirming transactions, and you won't get rewarded for your mining. Your chain will probably be overwritten the very next time you connect to the network.

> Where in the v0.9.3 code does it essentially say "if not connected to peers, then don't allow generation"?

[Here:](https://github.com/bitcoin/bitcoin/blob/0.9.3/src/miner.cpp#L512)

```
if (Params().NetworkID() != CChainParams::REGTEST) {
    // Busy-wait for the network to come online so we don't waste time mining
    // on an obsolete chain. In regtest mode we expect to fly solo.
    while (vNodes.empty())
        MilliSleep(1000);
}

```

[It's here on versions after 0.9.3:](https://github.com/bitcoin/bitcoin/blob/ed98a6284b4c2f0be2e128dc7cf59d42eb49046c/src/chainparams.cpp#L171)

```
fMiningRequiresPeers = true;

```

[This commit](https://github.com/bitcoin/bitcoin/commit/1712adbe0b084b6907b82db350a51ab44f8c3117) changed it.

> **Comments:**
> **username_0**: The `fMiningRequiresPeers = true` isn't on v0.9.3... ?  
> **username_1**: @StephenM347 So it isn't. Fixed.  
> **username_0**: And it may be pointless, but my point was that (I thought) it wasn't harmful. It seems like from the comment in the code, though, that allowing mining while not connected might actually be harmful because you could waste time mining on an obsolete chain. This also shows me where to change if I want to temporarily disable this for debugging, so thanks!  

---

