<p>It looks like the relevant code is in <code>CheckForWarningConditions()</code>.  This sets the flags <code>fLargeWorkForkFound</code> and <code>fLargeWorkInvalidChainFound</code>, which are checked by <code>GetWarnings()</code>, which is called in <code>CRPCTable::execute()</code> to check if safe mode should be enforced.</p>

<p>It appears that the code looks for large forks in the block chain, suggesting that miners disagree on which blocks are valid.  The two flags seem to correspond to which camp our client falls in.</p>

CC BY-SA 3.0
2014-04-17T15:55:27.170Z
2014-04-17T15:55:27.170Z
Nate Eldredge
<p>While reading through the bitcoin wiki I found this following segment describing a bitcoin RPC safe-mode</p>

<blockquote>
  <p>Until version 0.3.20, Bitcoin went into safe mode when a valid alert
  was received. In safe mode, all RPC commands that send BTC or get info
  about received BTC return an error. Current Bitcoin versions no longer
  go into safe mode in response to alerts, though Bitcoin will still go
  into safe mode when it detects on its own that something is seriously
  wrong with the network.</p>
  
  <p>Even though Bitcoin no longer automatically disables RPC when an alert
  is live, it is wise for Bitcoin sites to shut down when an alert has
  been issued. To detect an active alert, poll the "errors" field of
  getinfo.</p>
  
  <p>To test safe mode, run Bitcoin with the -testsafemode switch. To
  override a real safe mode event, run Bitcoin with the -disablesafemode
  switch.</p>
  
  <p><a href="https://en.bitcoin.it/wiki/Alerts#Safe_mode" rel="nofollow">https://en.bitcoin.it/wiki/Alerts#Safe_mode</a></p>
</blockquote>

<p>It says "Bitcoin will still go into safe mode when it detects on its own that something is seriously wrong with the network." I am interested in learning which events would make bitcoin go in to safe mode on it's own.</p>

<safemode>
What triggers safe-mode?
Mark
# What triggers safe-mode?

(Asked by: username_0 on 2014-04-17)

While reading through the bitcoin wiki I found this following segment describing a bitcoin RPC safe-mode

> Until version 0.3.20, Bitcoin went into safe mode when a valid alert
> was received. In safe mode, all RPC commands that send BTC or get info
> about received BTC return an error. Current Bitcoin versions no longer
> go into safe mode in response to alerts, though Bitcoin will still go
> into safe mode when it detects on its own that something is seriously
> wrong with the network.
>
> Even though Bitcoin no longer automatically disables RPC when an alert
> is live, it is wise for Bitcoin sites to shut down when an alert has
> been issued. To detect an active alert, poll the "errors" field of
> getinfo.
>
> To test safe mode, run Bitcoin with the -testsafemode switch. To
> override a real safe mode event, run Bitcoin with the -disablesafemode
> switch.
>
> <https://en.bitcoin.it/wiki/Alerts#Safe_mode>

It says "Bitcoin will still go into safe mode when it detects on its own that something is seriously wrong with the network." I am interested in learning which events would make bitcoin go in to safe mode on it's own.

**Tags:** safemode


---

## 1 answers

### Answer by username_1 on 2014-04-17. Score: 2

It looks like the relevant code is in `CheckForWarningConditions()`. This sets the flags `fLargeWorkForkFound` and `fLargeWorkInvalidChainFound`, which are checked by `GetWarnings()`, which is called in `CRPCTable::execute()` to check if safe mode should be enforced.

It appears that the code looks for large forks in the block chain, suggesting that miners disagree on which blocks are valid. The two flags seem to correspond to which camp our client falls in.


---

