Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

extend setgenerate RPC-call with 2 pre-checks #1989

Closed
wants to merge 1 commit into from

3 participants

@Diapolo
  • if we are not connected and if we are downloading the block-chain don't start the mining threads
  • this pull makes the setgenerate-call explicit, which I found out to be a good thing as we don't have 4 idle threads when not needed and it prevents mining under erroneous conditions (which I was able to trigger sometimes before this patch and which lead to orphan blocks)
  • the internal miner is only used for testnet anyway these days, but I love it for that scenario
@Diapolo Diapolo extend setgenerate RPC-call with 2 pre-checks
- if we are not connected and if we are downloading the block-chain don't
  start the mining threads
- this pull makes the setgenerate-call explicit, which I found out to be a
  good thing as we don't have 4 idle threads when not needed and it
  prevents mining under erroneous conditions (which I was able to trigger
  sometimes before this patch and which lead to orphan blocks)
- the internal miner is only used for testnet anyway these days, but I
  love it for that scenario
be18536
@jgarzik
Owner

I understand the motivation -- I use the internal miner every day on testnet -- but this change would defeat anyone who scripts setgenerate-on-startup, because it does not automatically re-enable mining once IBD is complete.

@Diapolo

You are right, but to automatically enable the miner it would still be possible to use -gen or set it via the bitcoin.conf. But if you see no way that this options suffice, you are free to close the pull.

@gavinandresen

I agree with jgarzik. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 5, 2012
  1. @Diapolo

    extend setgenerate RPC-call with 2 pre-checks

    Diapolo authored
    - if we are not connected and if we are downloading the block-chain don't
      start the mining threads
    - this pull makes the setgenerate-call explicit, which I found out to be a
      good thing as we don't have 4 idle threads when not needed and it
      prevents mining under erroneous conditions (which I was able to trigger
      sometimes before this patch and which lead to orphan blocks)
    - the internal miner is only used for testnet anyway these days, but I
      love it for that scenario
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/rpcmining.cpp
View
6 src/rpcmining.cpp
@@ -30,6 +30,12 @@ Value setgenerate(const Array& params, bool fHelp)
"<generate> is true or false to turn generation on or off.\n"
"Generation is limited to [genproclimit] processors, -1 is unlimited.");
+ if (vNodes.empty())
+ throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Bitcoin is not connected!");
+
+ if (IsInitialBlockDownload())
+ throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Bitcoin is downloading blocks...");
+
bool fGenerate = true;
if (params.size() > 0)
fGenerate = params[0].get_bool();
Something went wrong with that request. Please try again.