[DEV-127] remove getwork rpc command

This commit is contained in:
Ori Newman 2018-09-23 11:23:56 +03:00 committed by stasatdaglabs
parent 5fb220c38a
commit 21e9fde74d
4 changed files with 1 additions and 124 deletions

View File

@ -526,22 +526,6 @@ func NewGetTxOutSetInfoCmd() *GetTxOutSetInfoCmd {
return &GetTxOutSetInfoCmd{}
}
// GetWorkCmd defines the getwork JSON-RPC command.
type GetWorkCmd struct {
Data *string
}
// NewGetWorkCmd returns a new instance which can be used to issue a getwork
// JSON-RPC command.
//
// The parameters which are pointers indicate they are optional. Passing nil
// for optional parameters will use the default value.
func NewGetWorkCmd(data *string) *GetWorkCmd {
return &GetWorkCmd{
Data: data,
}
}
// HelpCmd defines the help JSON-RPC command.
type HelpCmd struct {
Command *string
@ -809,7 +793,6 @@ func init() {
MustRegisterCmd("gettxout", (*GetTxOutCmd)(nil), flags)
MustRegisterCmd("gettxoutproof", (*GetTxOutProofCmd)(nil), flags)
MustRegisterCmd("gettxoutsetinfo", (*GetTxOutSetInfoCmd)(nil), flags)
MustRegisterCmd("getwork", (*GetWorkCmd)(nil), flags)
MustRegisterCmd("help", (*HelpCmd)(nil), flags)
MustRegisterCmd("invalidateblock", (*InvalidateBlockCmd)(nil), flags)
MustRegisterCmd("ping", (*PingCmd)(nil), flags)

View File

@ -651,32 +651,6 @@ func TestDAGSvrCmds(t *testing.T) {
marshalled: `{"jsonrpc":"1.0","method":"gettxoutsetinfo","params":[],"id":1}`,
unmarshalled: &btcjson.GetTxOutSetInfoCmd{},
},
{
name: "getwork",
newCmd: func() (interface{}, error) {
return btcjson.NewCmd("getwork")
},
staticCmd: func() interface{} {
return btcjson.NewGetWorkCmd(nil)
},
marshalled: `{"jsonrpc":"1.0","method":"getwork","params":[],"id":1}`,
unmarshalled: &btcjson.GetWorkCmd{
Data: nil,
},
},
{
name: "getwork optional",
newCmd: func() (interface{}, error) {
return btcjson.NewCmd("getwork", "00112233")
},
staticCmd: func() interface{} {
return btcjson.NewGetWorkCmd(btcjson.String("00112233"))
},
marshalled: `{"jsonrpc":"1.0","method":"getwork","params":["00112233"],"id":1}`,
unmarshalled: &btcjson.GetWorkCmd{
Data: btcjson.String("00112233"),
},
},
{
name: "help",
newCmd: func() (interface{}, error) {

View File

@ -284,85 +284,6 @@ func (c *Client) GetNetworkHashPS3(blocks, height int) (int64, error) {
return c.GetNetworkHashPS3Async(blocks, height).Receive()
}
// FutureGetWork is a future promise to deliver the result of a
// GetWorkAsync RPC invocation (or an applicable error).
type FutureGetWork chan *response
// Receive waits for the response promised by the future and returns the hash
// data to work on.
func (r FutureGetWork) Receive() (*btcjson.GetWorkResult, error) {
res, err := receiveFuture(r)
if err != nil {
return nil, err
}
// Unmarshal result as a getwork result object.
var result btcjson.GetWorkResult
err = json.Unmarshal(res, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// GetWorkAsync returns an instance of a type that can be used to get the result
// of the RPC at some future time by invoking the Receive function on the
// returned instance.
//
// See GetWork for the blocking version and more details.
func (c *Client) GetWorkAsync() FutureGetWork {
cmd := btcjson.NewGetWorkCmd(nil)
return c.sendCmd(cmd)
}
// GetWork returns hash data to work on.
//
// See GetWorkSubmit to submit the found solution.
func (c *Client) GetWork() (*btcjson.GetWorkResult, error) {
return c.GetWorkAsync().Receive()
}
// FutureGetWorkSubmit is a future promise to deliver the result of a
// GetWorkSubmitAsync RPC invocation (or an applicable error).
type FutureGetWorkSubmit chan *response
// Receive waits for the response promised by the future and returns whether
// or not the submitted block header was accepted.
func (r FutureGetWorkSubmit) Receive() (bool, error) {
res, err := receiveFuture(r)
if err != nil {
return false, err
}
// Unmarshal result as a boolean.
var accepted bool
err = json.Unmarshal(res, &accepted)
if err != nil {
return false, err
}
return accepted, nil
}
// GetWorkSubmitAsync returns an instance of a type that can be used to get the
// result of the RPC at some future time by invoking the Receive function on the
// returned instance.
//
// See GetWorkSubmit for the blocking version and more details.
func (c *Client) GetWorkSubmitAsync(data string) FutureGetWorkSubmit {
cmd := btcjson.NewGetWorkCmd(&data)
return c.sendCmd(cmd)
}
// GetWorkSubmit submits a block header which is a solution to previously
// requested data and returns whether or not the solution was accepted.
//
// See GetWork to request data to work on.
func (c *Client) GetWorkSubmit(data string) (bool, error) {
return c.GetWorkSubmitAsync(data).Receive()
}
// FutureSubmitBlockResult is a future promise to deliver the result of a
// SubmitBlockAsync RPC invocation (or an applicable error).
type FutureSubmitBlockResult chan *response

View File

@ -236,7 +236,6 @@ var rpcUnimplemented = map[string]struct{}{
"getchaintips": {},
"getmempoolentry": {},
"getnetworkinfo": {},
"getwork": {},
"invalidateblock": {},
"preciousblock": {},
"reconsiderblock": {},
@ -4195,7 +4194,7 @@ func NewRPCServer(
gbtWorkState: newGbtWorkState(cfg.TimeSource),
helpCacher: newHelpCacher(),
requestProcessShutdown: make(chan struct{}),
quit: make(chan int),
quit: make(chan int),
}
if config.MainConfig().RPCUser != "" && config.MainConfig().RPCPass != "" {
login := config.MainConfig().RPCUser + ":" + config.MainConfig().RPCPass