[NOD-355] remove 'flushDbCache' and 'getBlockHash' rpc commands (#425)

* [NOD-355] remove 'flushDbCache' and 'getBlockHash' rpc commands

* [NOD-355] remove 'flushDbCache' and 'getBlockHash' from rpc server help
This commit is contained in:
Dan Aharoni 2019-10-07 14:07:20 +03:00 committed by stasatdaglabs
parent 9dfc3091b4
commit 40ad9c5d2b
7 changed files with 0 additions and 84 deletions

View File

@ -190,19 +190,6 @@ func NewGetBlockCountCmd() *GetBlockCountCmd {
return &GetBlockCountCmd{}
}
// GetBlockHashCmd defines the getBlockHash JSON-RPC command.
type GetBlockHashCmd struct {
Index int64
}
// NewGetBlockHashCmd returns a new instance which can be used to issue a
// getBlockHash JSON-RPC command.
func NewGetBlockHashCmd(index int64) *GetBlockHashCmd {
return &GetBlockHashCmd{
Index: index,
}
}
// GetBlockHeaderCmd defines the getBlockHeader JSON-RPC command.
type GetBlockHeaderCmd struct {
Hash string
@ -218,17 +205,6 @@ func NewGetBlockHeaderCmd(hash string, verbose *bool) *GetBlockHeaderCmd {
}
}
// FlushDBCacheCmd defines the flushDbCache JSON-RPC command.
// TODO: (Ori) This is a temporary function for dev use. It needs to be removed.
type FlushDBCacheCmd struct{}
// NewFlushDBCacheCmd returns a new instance which can be used to issue a
// flushDbCache JSON-RPC command.
// TODO: (Ori) This is a temporary function for dev use. It needs to be removed.
func NewFlushDBCacheCmd(hash string, verbose *bool) *FlushDBCacheCmd {
return &FlushDBCacheCmd{}
}
// TemplateRequest is a request object as defined in BIP22
// (https://en.bitcoin.it/wiki/BIP_0022), it is optionally provided as an
// pointer argument to GetBlockTemplateCmd.
@ -817,7 +793,6 @@ func init() {
MustRegisterCmd("getBlocks", (*GetBlocksCmd)(nil), flags)
MustRegisterCmd("getBlockDagInfo", (*GetBlockDAGInfoCmd)(nil), flags)
MustRegisterCmd("getBlockCount", (*GetBlockCountCmd)(nil), flags)
MustRegisterCmd("getBlockHash", (*GetBlockHashCmd)(nil), flags)
MustRegisterCmd("getBlockHeader", (*GetBlockHeaderCmd)(nil), flags)
MustRegisterCmd("getBlockTemplate", (*GetBlockTemplateCmd)(nil), flags)
MustRegisterCmd("getCFilter", (*GetCFilterCmd)(nil), flags)
@ -858,5 +833,4 @@ func init() {
MustRegisterCmd("validateAddress", (*ValidateAddressCmd)(nil), flags)
MustRegisterCmd("verifyMessage", (*VerifyMessageCmd)(nil), flags)
MustRegisterCmd("verifyTxOutProof", (*VerifyTxOutProofCmd)(nil), flags)
MustRegisterCmd("flushDbCache", (*FlushDBCacheCmd)(nil), flags)
}

View File

@ -227,17 +227,6 @@ func TestDAGSvrCmds(t *testing.T) {
marshalled: `{"jsonrpc":"1.0","method":"getBlockCount","params":[],"id":1}`,
unmarshalled: &btcjson.GetBlockCountCmd{},
},
{
name: "getBlockHash",
newCmd: func() (interface{}, error) {
return btcjson.NewCmd("getBlockHash", 123)
},
staticCmd: func() interface{} {
return btcjson.NewGetBlockHashCmd(123)
},
marshalled: `{"jsonrpc":"1.0","method":"getBlockHash","params":[123],"id":1}`,
unmarshalled: &btcjson.GetBlockHashCmd{Index: 123},
},
{
name: "getBlockHeader",
newCmd: func() (interface{}, error) {

View File

@ -382,22 +382,6 @@ func (r FutureGetBlockHashResult) Receive() (*daghash.Hash, error) {
return daghash.NewHashFromStr(txHashStr)
}
// GetBlockHashAsync 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 GetBlockHash for the blocking version and more details.
func (c *Client) GetBlockHashAsync(blockHeight int64) FutureGetBlockHashResult {
cmd := btcjson.NewGetBlockHashCmd(blockHeight)
return c.sendCmd(cmd)
}
// GetBlockHash returns the hash of the block in the best block dag at the
// given height.
func (c *Client) GetBlockHash(blockHeight int64) (*daghash.Hash, error) {
return c.GetBlockHashAsync(blockHeight).Receive()
}
// FutureGetBlockHeaderResult is a future promise to deliver the result of a
// GetBlockHeaderAsync RPC invocation (or an applicable error).
type FutureGetBlockHeaderResult chan *response

View File

@ -1,8 +0,0 @@
package rpc
// handleFlushDBCache flushes the db cache to the disk.
// TODO: (Ori) This is a temporary function for dev use. It needs to be removed.
func handleFlushDBCache(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
err := s.cfg.DB.FlushCache()
return nil, err
}

View File

@ -1,8 +0,0 @@
package rpc
// handleGetBlockHash implements the getBlockHash command.
// This command had been (possibly temporarily) dropped.
// Originally it relied on height, which no longer makes sense.
func handleGetBlockHash(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
return nil, ErrRPCUnimplemented
}

View File

@ -72,7 +72,6 @@ var rpcHandlersBeforeInit = map[string]commandHandler{
"getBlocks": handleGetBlocks,
"getBlockDagInfo": handleGetBlockDAGInfo,
"getBlockCount": handleGetBlockCount,
"getBlockHash": handleGetBlockHash,
"getBlockHeader": handleGetBlockHeader,
"getBlockTemplate": handleGetBlockTemplate,
"getCFilter": handleGetCFilter,
@ -109,7 +108,6 @@ var rpcHandlersBeforeInit = map[string]commandHandler{
"validateAddress": handleValidateAddress,
"verifyMessage": handleVerifyMessage,
"version": handleVersion,
"flushDbCache": handleFlushDBCache,
}
// Commands that are currently unimplemented, but should ultimately be.

View File

@ -273,11 +273,6 @@ var helpDescsEnUS = map[string]string{
"getBlockCount--synopsis": "Returns the number of blocks in the longest block chain.",
"getBlockCount--result0": "The current block count",
// GetBlockHashCmd help.
"getBlockHash--synopsis": "Returns hash of the block in best block chain at the given height.",
"getBlockHash-index": "The block height",
"getBlockHash--result0": "The block hash",
// GetBlockHeaderCmd help.
"getBlockHeader--synopsis": "Returns information about a block header given its hash.",
"getBlockHeader-hash": "The hash of the block",
@ -674,12 +669,6 @@ var helpDescsEnUS = map[string]string{
"versionResult-patch": "The patch component of the JSON-RPC API version",
"versionResult-prerelease": "Prerelease info about the current build",
"versionResult-buildMetadata": "Metadata about the current build",
// TODO: (Ori) This is a temporary rpc command for dev use. It needs to be removed.
"flushDbCache--synopsis": "No Synopsis",
"flushDbCache--result0--desc": "No Result",
"flushDbCache--result0--value": "No Value",
"flushDbCache--result0--key": "No Key",
}
// rpcResultTypes specifies the result types that each RPC command can return.
@ -698,7 +687,6 @@ var rpcResultTypes = map[string][]interface{}{
"getBlock": {(*string)(nil), (*btcjson.GetBlockVerboseResult)(nil)},
"getBlocks": {(*btcjson.GetBlocksResult)(nil)},
"getBlockCount": {(*int64)(nil)},
"getBlockHash": {(*string)(nil)},
"getBlockHeader": {(*string)(nil), (*btcjson.GetBlockHeaderVerboseResult)(nil)},
"getBlockTemplate": {(*btcjson.GetBlockTemplateResult)(nil), (*string)(nil), nil},
"getBlockDagInfo": {(*btcjson.GetBlockDAGInfoResult)(nil)},
@ -736,7 +724,6 @@ var rpcResultTypes = map[string][]interface{}{
"validateAddress": {(*btcjson.ValidateAddressResult)(nil)},
"verifyMessage": {(*bool)(nil)},
"version": {(*map[string]btcjson.VersionResult)(nil)},
"flushDbCache": {(*map[string]struct{})(nil)},
// Websocket commands.
"loadTxFilter": nil,