Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create generate RPC command to close #362 #407

Merged
merged 1 commit into from
May 5, 2015

Conversation

aakselrod
Copy link
Contributor

Create GenerateCmd in btcjson v2. Update tests to check GenerateCmd.

Update chaincfg/params.go with a new bool in Params, GenerateSupported,
with true values in SimNetParams and RegressionNetParams and false in
the others.

Create new flag, discreteMining, in CPUMiner struct.

Add GenerateNBlocks function to cpuminer.go and handleGenerate
function to rpcserver.go.

Update documentation for the RPC calls.

@@ -58,6 +58,19 @@ func NewDebugLevelCmd(levelSpec string) *DebugLevelCmd {
}
}

// GenerateCmd defines the generate JSON-RPC command.
type GenerateCmd struct {
NumBlocks uint32 `json:"numblocks"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to specify the tag on the command. JSON-RPC 1.0 uses positional params.

EDIT: To clarify, the result needs it (as that's just normal JSON), but commands don't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

" array of their hashes.",
"generate-numblocks": "Number of blocks to generate",

// GenerateResult help
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super Nit: This comment can go away since the type has been removed. Once that goes away, so should the blank line above it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, removed comment/blank line.

@davecgh
Copy link
Member

davecgh commented Apr 30, 2015

Also, I managed to hit a case where it was generating a bunch of blocks and I issued a setgenerate false from another thread. That incorrectly allowed it to stop the mining process which leads to a (recovered) panic due to an attempted double close of the channel.

I believe this will need a separate flag to prevent any changes via setgenerate while discrete mining is active. The reverse case seem to already be covered (can't issue generate while mining is already active).

@aakselrod
Copy link
Contributor Author

ACK, I created a new discreteMining flag and check it in Stop(), Start(), and GenerateNBlocks where it's set/cleared.

@davecgh
Copy link
Member

davecgh commented May 4, 2015

Code updates look good. I'm testing it out now.

Create GenerateCmd in btcjson v2. Update tests to check GenerateCmd.

Update chaincfg/params.go with a new bool in Params, GenerateSupported,
with true values in SimNetParams and RegressionNetParams and false in
the others.

Create new flag, discreteMining, in CPUMiner struct.

Add GenerateNBlocks function to cpuminer.go and handleGenerate
function to rpcserver.go.

Update documentation for the RPC calls.
@conformal-deploy conformal-deploy merged commit d26aaff into btcsuite:master May 5, 2015
@aakselrod aakselrod deleted the generate-rpc branch May 5, 2015 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants