mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-04 13:16:43 +00:00
[NOD-340] Remove unimplemented RPC commands: getNetworkHashPS, estimatePriority, getChainTips, invalidateBlock, preciousBlock, reconsiderBlock (#528)
* [NOD-340] Remove GetNetworkHashPS cmd * [NOD-340] Removed unimplemented commands: estimatePriority, getChainTips, invalidateBlock, preciousBlock, reconsiderBlock * [NOD-340] Apply gofmt
This commit is contained in:
parent
8680231e5a
commit
189a3380a2
@ -5,7 +5,7 @@ btcd
|
||||
[](http://copyfree.org)
|
||||
[](http://godoc.org/github.com/kaspanet/kaspad)
|
||||
|
||||
btcd is an alternative full node bitcoin implementation written in Go (golang).
|
||||
Kaspad is the reference full node Kaspa implementation written in Go (golang).
|
||||
|
||||
This project is currently under active development and is in a Beta state. It
|
||||
is extremely stable and has been in production use since October 2013.
|
||||
|
@ -409,24 +409,6 @@ func NewGetNetTotalsCmd() *GetNetTotalsCmd {
|
||||
return &GetNetTotalsCmd{}
|
||||
}
|
||||
|
||||
// GetNetworkHashPSCmd defines the getNetworkHashPs JSON-RPC command.
|
||||
type GetNetworkHashPSCmd struct {
|
||||
Blocks *int `jsonrpcdefault:"120"`
|
||||
Height *int `jsonrpcdefault:"-1"`
|
||||
}
|
||||
|
||||
// NewGetNetworkHashPSCmd returns a new instance which can be used to issue a
|
||||
// getNetworkHashPs JSON-RPC command.
|
||||
//
|
||||
// The parameters which are pointers indicate they are optional. Passing nil
|
||||
// for optional parameters will use the default value.
|
||||
func NewGetNetworkHashPSCmd(numBlocks, height *int) *GetNetworkHashPSCmd {
|
||||
return &GetNetworkHashPSCmd{
|
||||
Blocks: numBlocks,
|
||||
Height: height,
|
||||
}
|
||||
}
|
||||
|
||||
// GetPeerInfoCmd defines the getPeerInfo JSON-RPC command.
|
||||
type GetPeerInfoCmd struct{}
|
||||
|
||||
@ -531,19 +513,6 @@ func NewHelpCmd(command *string) *HelpCmd {
|
||||
}
|
||||
}
|
||||
|
||||
// InvalidateBlockCmd defines the invalidateBlock JSON-RPC command.
|
||||
type InvalidateBlockCmd struct {
|
||||
BlockHash string
|
||||
}
|
||||
|
||||
// NewInvalidateBlockCmd returns a new instance which can be used to issue a
|
||||
// invalidateBlock JSON-RPC command.
|
||||
func NewInvalidateBlockCmd(blockHash string) *InvalidateBlockCmd {
|
||||
return &InvalidateBlockCmd{
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
}
|
||||
|
||||
// PingCmd defines the ping JSON-RPC command.
|
||||
type PingCmd struct{}
|
||||
|
||||
@ -553,32 +522,6 @@ func NewPingCmd() *PingCmd {
|
||||
return &PingCmd{}
|
||||
}
|
||||
|
||||
// PreciousBlockCmd defines the preciousBlock JSON-RPC command.
|
||||
type PreciousBlockCmd struct {
|
||||
BlockHash string
|
||||
}
|
||||
|
||||
// NewPreciousBlockCmd returns a new instance which can be used to issue a
|
||||
// preciousBlock JSON-RPC command.
|
||||
func NewPreciousBlockCmd(blockHash string) *PreciousBlockCmd {
|
||||
return &PreciousBlockCmd{
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
}
|
||||
|
||||
// ReconsiderBlockCmd defines the reconsiderBlock JSON-RPC command.
|
||||
type ReconsiderBlockCmd struct {
|
||||
BlockHash string
|
||||
}
|
||||
|
||||
// NewReconsiderBlockCmd returns a new instance which can be used to issue a
|
||||
// reconsiderBlock JSON-RPC command.
|
||||
func NewReconsiderBlockCmd(blockHash string) *ReconsiderBlockCmd {
|
||||
return &ReconsiderBlockCmd{
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
}
|
||||
|
||||
// SearchRawTransactionsCmd defines the searchRawTransactions JSON-RPC command.
|
||||
type SearchRawTransactionsCmd struct {
|
||||
Address string
|
||||
@ -727,7 +670,6 @@ func init() {
|
||||
MustRegisterCmd("getMiningInfo", (*GetMiningInfoCmd)(nil), flags)
|
||||
MustRegisterCmd("getNetworkInfo", (*GetNetworkInfoCmd)(nil), flags)
|
||||
MustRegisterCmd("getNetTotals", (*GetNetTotalsCmd)(nil), flags)
|
||||
MustRegisterCmd("getNetworkHashPs", (*GetNetworkHashPSCmd)(nil), flags)
|
||||
MustRegisterCmd("getPeerInfo", (*GetPeerInfoCmd)(nil), flags)
|
||||
MustRegisterCmd("getRawMempool", (*GetRawMempoolCmd)(nil), flags)
|
||||
MustRegisterCmd("getRawTransaction", (*GetRawTransactionCmd)(nil), flags)
|
||||
@ -735,10 +677,7 @@ func init() {
|
||||
MustRegisterCmd("getTxOut", (*GetTxOutCmd)(nil), flags)
|
||||
MustRegisterCmd("getTxOutSetInfo", (*GetTxOutSetInfoCmd)(nil), flags)
|
||||
MustRegisterCmd("help", (*HelpCmd)(nil), flags)
|
||||
MustRegisterCmd("invalidateBlock", (*InvalidateBlockCmd)(nil), flags)
|
||||
MustRegisterCmd("ping", (*PingCmd)(nil), flags)
|
||||
MustRegisterCmd("preciousBlock", (*PreciousBlockCmd)(nil), flags)
|
||||
MustRegisterCmd("reconsiderBlock", (*ReconsiderBlockCmd)(nil), flags)
|
||||
MustRegisterCmd("removeManualNode", (*RemoveManualNodeCmd)(nil), flags)
|
||||
MustRegisterCmd("searchRawTransactions", (*SearchRawTransactionsCmd)(nil), flags)
|
||||
MustRegisterCmd("sendRawTransaction", (*SendRawTransactionCmd)(nil), flags)
|
||||
|
@ -474,48 +474,6 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
marshalled: `{"jsonrpc":"1.0","method":"getNetTotals","params":[],"id":1}`,
|
||||
unmarshalled: &btcjson.GetNetTotalsCmd{},
|
||||
},
|
||||
{
|
||||
name: "getNetworkHashPs",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("getNetworkHashPs")
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewGetNetworkHashPSCmd(nil, nil)
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"getNetworkHashPs","params":[],"id":1}`,
|
||||
unmarshalled: &btcjson.GetNetworkHashPSCmd{
|
||||
Blocks: btcjson.Int(120),
|
||||
Height: btcjson.Int(-1),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "getNetworkHashPs optional1",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("getNetworkHashPs", 200)
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewGetNetworkHashPSCmd(btcjson.Int(200), nil)
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"getNetworkHashPs","params":[200],"id":1}`,
|
||||
unmarshalled: &btcjson.GetNetworkHashPSCmd{
|
||||
Blocks: btcjson.Int(200),
|
||||
Height: btcjson.Int(-1),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "getNetworkHashPs optional2",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("getNetworkHashPs", 200, 123)
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewGetNetworkHashPSCmd(btcjson.Int(200), btcjson.Int(123))
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"getNetworkHashPs","params":[200,123],"id":1}`,
|
||||
unmarshalled: &btcjson.GetNetworkHashPSCmd{
|
||||
Blocks: btcjson.Int(200),
|
||||
Height: btcjson.Int(123),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "getPeerInfo",
|
||||
newCmd: func() (interface{}, error) {
|
||||
@ -661,19 +619,6 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
Command: btcjson.String("getBlock"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalidateBlock",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("invalidateBlock", "123")
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewInvalidateBlockCmd("123")
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"invalidateBlock","params":["123"],"id":1}`,
|
||||
unmarshalled: &btcjson.InvalidateBlockCmd{
|
||||
BlockHash: "123",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ping",
|
||||
newCmd: func() (interface{}, error) {
|
||||
@ -685,32 +630,6 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
marshalled: `{"jsonrpc":"1.0","method":"ping","params":[],"id":1}`,
|
||||
unmarshalled: &btcjson.PingCmd{},
|
||||
},
|
||||
{
|
||||
name: "preciousBlock",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("preciousBlock", "0123")
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewPreciousBlockCmd("0123")
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"preciousBlock","params":["0123"],"id":1}`,
|
||||
unmarshalled: &btcjson.PreciousBlockCmd{
|
||||
BlockHash: "0123",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "reconsiderBlock",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("reconsiderBlock", "123")
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewReconsiderBlockCmd("123")
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"reconsiderBlock","params":["123"],"id":1}`,
|
||||
unmarshalled: &btcjson.ReconsiderBlockCmd{
|
||||
BlockHash: "123",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "removeManualNode",
|
||||
newCmd: func() (interface{}, error) {
|
||||
|
@ -400,7 +400,6 @@ type GetMiningInfoResult struct {
|
||||
Generate bool `json:"generate"`
|
||||
GenProcLimit int32 `json:"genProcLimit"`
|
||||
HashesPerSec int64 `json:"hashesPerSec"`
|
||||
NetworkHashPS int64 `json:"networkHashPs"`
|
||||
PooledTx uint64 `json:"pooledTx"`
|
||||
TestNet bool `json:"testNet"`
|
||||
DevNet bool `json:"devNet"`
|
||||
|
@ -175,7 +175,6 @@ the method name for further details such as parameter and return information.
|
||||
|16|[getmempoolinfo](#getmempoolinfo)|N|Returns a JSON object containing mempool-related information.|
|
||||
|17|[getmininginfo](#getmininginfo)|N|Returns a JSON object containing mining-related information.|
|
||||
|18|[getnettotals](#getnettotals)|Y|Returns a JSON object containing network traffic statistics.|
|
||||
|19|[getnetworkhashps](#getnetworkhashps)|Y|Returns the estimated network hashes per second for the block heights provided by the parameters.|
|
||||
|20|[getpeerinfo](#getpeerinfo)|N|Returns information about each connected network peer as an array of json objects.|
|
||||
|21|[getrawmempool](#getrawmempool)|Y|Returns an array of hashes for all of the transactions currently in the memory pool.|
|
||||
|22|[getrawtransaction](#getrawtransaction)|Y|Returns information about a transaction given its hash.|
|
||||
@ -397,8 +396,8 @@ Example Return|`{`<br /> `"bytes": 310768,`<br /> `"size":
|
||||
|Method|getmininginfo|
|
||||
|Parameters|None|
|
||||
|Description|Returns a JSON object containing mining-related information.|
|
||||
|Returns|`{ (json object)`<br /> `"blocks": n, (numeric) latest best block`<br /> `"currentblocksize": n, (numeric) size of the latest best block`<br /> `"currentblocktx": n, (numeric) number of transactions in the latest best block`<br /> `"difficulty": n.nn, (numeric) current target difficulty`<br /> `"errors": "errors", (string) any current errors`<br /> `"generate": true or false, (boolean) whether or not server is set to generate coins`<br /> `"genproclimit": n, (numeric) number of processors to use for coin generation (-1 when disabled)`<br /> `"hashespersec": n, (numeric) recent hashes per second performance measurement while generating coins`<br /> `"networkhashps": n, (numeric) estimated network hashes per second for the most recent blocks`<br /> `"pooledtx": n, (numeric) number of transactions in the memory pool`<br /> `"testnet": true or false, (boolean) whether or not server is using testnet`<br />`}`|
|
||||
|Example Return|`{`<br /> `"blocks": 236526,`<br /> `"currentblocksize": 185,`<br /> `"currentblocktx": 1,`<br /> `"difficulty": 256,`<br /> `"errors": "",`<br /> `"generate": false,`<br /> `"genproclimit": -1,`<br /> `"hashespersec": 0,`<br /> `"networkhashps": 33081554756,`<br /> `"pooledtx": 8,`<br /> `"testnet": true,`<br />`}`|
|
||||
|Returns|`{ (json object)`<br /> `"blocks": n, (numeric) latest best block`<br /> `"currentblocksize": n, (numeric) size of the latest best block`<br /> `"currentblocktx": n, (numeric) number of transactions in the latest best block`<br /> `"difficulty": n.nn, (numeric) current target difficulty`<br /> `"errors": "errors", (string) any current errors`<br /> `"generate": true or false, (boolean) whether or not server is set to generate coins`<br /> `"genproclimit": n, (numeric) number of processors to use for coin generation (-1 when disabled)`<br /> `"hashespersec": n, (numeric) recent hashes per second performance measurement while generating coins`<br /> `"pooledtx": n, (numeric) number of transactions in the memory pool`<br /> `"testnet": true or false, (boolean) whether or not server is using testnet`<br />`}`|
|
||||
|Example Return|`{`<br /> `"blocks": 236526,`<br /> `"currentblocksize": 185,`<br /> `"currentblocktx": 1,`<br /> `"difficulty": 256,`<br /> `"errors": "",`<br /> `"generate": false,`<br /> `"genproclimit": -1,`<br /> `"hashespersec": 0,`<br /> `"pooledtx": 8,`<br /> `"testnet": true,`<br />`}`|
|
||||
[Return to Overview](#MethodOverview)<br />
|
||||
|
||||
***
|
||||
@ -413,18 +412,6 @@ Example Return|`{`<br /> `"bytes": 310768,`<br /> `"size":
|
||||
|Example Return|`{`<br /> `"totalbytesrecv": 1150990,`<br /> `"totalbytessent": 206739,`<br /> `"timemillis": 1391626433845`<br />`}`|
|
||||
[Return to Overview](#MethodOverview)<br />
|
||||
|
||||
***
|
||||
<a name="getnetworkhashps"/>
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|Method|getnetworkhashps|
|
||||
|Parameters|1. blocks (numeric, optional, default=120) - The number of blocks, or -1 for blocks since last difficulty change<br />2. height (numeric, optional, default=-1) - Perform estimate ending with this height or -1 for current best chain block height|
|
||||
|Description|Returns the estimated network hashes per second for the block heights provided by the parameters.|
|
||||
|Returns|numeric|
|
||||
|Example Return|`6573971939`|
|
||||
[Return to Overview](#MethodOverview)<br />
|
||||
|
||||
***
|
||||
<a name="getpeerinfo"/>
|
||||
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/kaspanet/kaspad/btcjson"
|
||||
@ -756,35 +757,3 @@ func (c *Client) RescanBlocksAsync(blockHashes []*daghash.Hash) FutureRescanBloc
|
||||
func (c *Client) RescanBlocks(blockHashes []*daghash.Hash) ([]btcjson.RescannedBlock, error) {
|
||||
return c.RescanBlocksAsync(blockHashes).Receive()
|
||||
}
|
||||
|
||||
// FutureInvalidateBlockResult is a future promise to deliver the result of a
|
||||
// InvalidateBlockAsync RPC invocation (or an applicable error).
|
||||
type FutureInvalidateBlockResult chan *response
|
||||
|
||||
// Receive waits for the response promised by the future and returns the raw
|
||||
// block requested from the server given its hash.
|
||||
func (r FutureInvalidateBlockResult) Receive() error {
|
||||
_, err := receiveFuture(r)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// InvalidateBlockAsync 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 InvalidateBlock for the blocking version and more details.
|
||||
func (c *Client) InvalidateBlockAsync(blockHash *daghash.Hash) FutureInvalidateBlockResult {
|
||||
hash := ""
|
||||
if blockHash != nil {
|
||||
hash = blockHash.String()
|
||||
}
|
||||
|
||||
cmd := btcjson.NewInvalidateBlockCmd(hash)
|
||||
return c.sendCmd(cmd)
|
||||
}
|
||||
|
||||
// InvalidateBlock invalidates a specific block.
|
||||
func (c *Client) InvalidateBlock(blockHash *daghash.Hash) error {
|
||||
return c.InvalidateBlockAsync(blockHash).Receive()
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ package rpcclient
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/kaspanet/kaspad/btcjson"
|
||||
"github.com/kaspanet/kaspad/util"
|
||||
"github.com/kaspanet/kaspad/util/daghash"
|
||||
@ -200,89 +201,6 @@ func (c *Client) GetMiningInfo() (*btcjson.GetMiningInfoResult, error) {
|
||||
return c.GetMiningInfoAsync().Receive()
|
||||
}
|
||||
|
||||
// FutureGetNetworkHashPS is a future promise to deliver the result of a
|
||||
// GetNetworkHashPSAsync RPC invocation (or an applicable error).
|
||||
type FutureGetNetworkHashPS chan *response
|
||||
|
||||
// Receive waits for the response promised by the future and returns the
|
||||
// estimated network hashes per second for the block heights provided by the
|
||||
// parameters.
|
||||
func (r FutureGetNetworkHashPS) Receive() (int64, error) {
|
||||
res, err := receiveFuture(r)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
// Unmarshal result as an int64.
|
||||
var result int64
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetNetworkHashPSAsync 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 GetNetworkHashPS for the blocking version and more details.
|
||||
func (c *Client) GetNetworkHashPSAsync() FutureGetNetworkHashPS {
|
||||
cmd := btcjson.NewGetNetworkHashPSCmd(nil, nil)
|
||||
return c.sendCmd(cmd)
|
||||
}
|
||||
|
||||
// GetNetworkHashPS returns the estimated network hashes per second using the
|
||||
// default number of blocks and the most recent block height.
|
||||
//
|
||||
// See GetNetworkHashPS2 to override the number of blocks to use and
|
||||
// GetNetworkHashPS3 to override the height at which to calculate the estimate.
|
||||
func (c *Client) GetNetworkHashPS() (int64, error) {
|
||||
return c.GetNetworkHashPSAsync().Receive()
|
||||
}
|
||||
|
||||
// GetNetworkHashPS2Async 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 GetNetworkHashPS2 for the blocking version and more details.
|
||||
func (c *Client) GetNetworkHashPS2Async(blocks int) FutureGetNetworkHashPS {
|
||||
cmd := btcjson.NewGetNetworkHashPSCmd(&blocks, nil)
|
||||
return c.sendCmd(cmd)
|
||||
}
|
||||
|
||||
// GetNetworkHashPS2 returns the estimated network hashes per second for the
|
||||
// specified previous number of blocks working backwards from the most recent
|
||||
// block height. The blocks parameter can also be -1 in which case the number
|
||||
// of blocks since the last difficulty change will be used.
|
||||
//
|
||||
// See GetNetworkHashPS to use defaults and GetNetworkHashPS3 to override the
|
||||
// height at which to calculate the estimate.
|
||||
func (c *Client) GetNetworkHashPS2(blocks int) (int64, error) {
|
||||
return c.GetNetworkHashPS2Async(blocks).Receive()
|
||||
}
|
||||
|
||||
// GetNetworkHashPS3Async 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 GetNetworkHashPS3 for the blocking version and more details.
|
||||
func (c *Client) GetNetworkHashPS3Async(blocks, height int) FutureGetNetworkHashPS {
|
||||
cmd := btcjson.NewGetNetworkHashPSCmd(&blocks, &height)
|
||||
return c.sendCmd(cmd)
|
||||
}
|
||||
|
||||
// GetNetworkHashPS3 returns the estimated network hashes per second for the
|
||||
// specified previous number of blocks working backwards from the specified
|
||||
// block height. The blocks parameter can also be -1 in which case the number
|
||||
// of blocks since the last difficulty change will be used.
|
||||
//
|
||||
// See GetNetworkHashPS and GetNetworkHashPS2 to use defaults.
|
||||
func (c *Client) GetNetworkHashPS3(blocks, height int) (int64, error) {
|
||||
return c.GetNetworkHashPS3Async(blocks, height).Receive()
|
||||
}
|
||||
|
||||
// FutureSubmitBlockResult is a future promise to deliver the result of a
|
||||
// SubmitBlockAsync RPC invocation (or an applicable error).
|
||||
type FutureSubmitBlockResult chan *response
|
||||
|
@ -15,22 +15,6 @@ func handleGetMiningInfo(s *Server, cmd interface{}, closeChan <-chan struct{})
|
||||
}
|
||||
}
|
||||
|
||||
// Create a default getNetworkHashPs command to use defaults and make
|
||||
// use of the existing getNetworkHashPs handler.
|
||||
gnhpsCmd := btcjson.NewGetNetworkHashPSCmd(nil, nil)
|
||||
networkHashesPerSecIface, err := handleGetNetworkHashPS(s, gnhpsCmd,
|
||||
closeChan)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
networkHashesPerSec, ok := networkHashesPerSecIface.(int64)
|
||||
if !ok {
|
||||
return nil, &btcjson.RPCError{
|
||||
Code: btcjson.ErrRPCInternal.Code,
|
||||
Message: "networkHashesPerSec is not an int64",
|
||||
}
|
||||
}
|
||||
|
||||
selectedTipHash := s.cfg.DAG.SelectedTipHash()
|
||||
selectedBlock, err := s.cfg.DAG.BlockByHash(selectedTipHash)
|
||||
if err != nil {
|
||||
@ -48,7 +32,6 @@ func handleGetMiningInfo(s *Server, cmd interface{}, closeChan <-chan struct{})
|
||||
Generate: s.cfg.CPUMiner.IsMining(),
|
||||
GenProcLimit: s.cfg.CPUMiner.NumWorkers(),
|
||||
HashesPerSec: int64(s.cfg.CPUMiner.HashesPerSecond()),
|
||||
NetworkHashPS: networkHashesPerSec,
|
||||
PooledTx: uint64(s.cfg.TxMemPool.Count()),
|
||||
TestNet: config.ActiveConfig().TestNet,
|
||||
DevNet: config.ActiveConfig().DevNet,
|
||||
|
@ -1,20 +0,0 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/btcjson"
|
||||
"github.com/kaspanet/kaspad/config"
|
||||
)
|
||||
|
||||
// handleGetNetworkHashPS implements the getNetworkHashPs command.
|
||||
// This command had been (possibly temporarily) dropped.
|
||||
// Originally it relied on height, which no longer makes sense.
|
||||
func handleGetNetworkHashPS(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
||||
if config.ActiveConfig().SubnetworkID != nil {
|
||||
return nil, &btcjson.RPCError{
|
||||
Code: btcjson.ErrRPCInvalidRequest.Code,
|
||||
Message: "`getNetworkHashPS` is not supported on partial nodes.",
|
||||
}
|
||||
}
|
||||
|
||||
return nil, ErrRPCUnimplemented
|
||||
}
|
@ -2,6 +2,7 @@ package rpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kaspanet/kaspad/btcjson"
|
||||
"github.com/kaspanet/kaspad/util/daghash"
|
||||
)
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
@ -23,6 +22,8 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/btcsuite/websocket"
|
||||
"github.com/kaspanet/kaspad/blockdag"
|
||||
"github.com/kaspanet/kaspad/blockdag/indexers"
|
||||
@ -87,7 +88,6 @@ var rpcHandlersBeforeInit = map[string]commandHandler{
|
||||
"getMempoolInfo": handleGetMempoolInfo,
|
||||
"getMiningInfo": handleGetMiningInfo,
|
||||
"getNetTotals": handleGetNetTotals,
|
||||
"getNetworkHashPs": handleGetNetworkHashPS,
|
||||
"getPeerInfo": handleGetPeerInfo,
|
||||
"getRawMempool": handleGetRawMempool,
|
||||
"getRawTransaction": handleGetRawTransaction,
|
||||
@ -109,13 +109,8 @@ var rpcHandlersBeforeInit = map[string]commandHandler{
|
||||
|
||||
// Commands that are currently unimplemented, but should ultimately be.
|
||||
var rpcUnimplemented = map[string]struct{}{
|
||||
"estimatePriority": {},
|
||||
"getChainTips": {},
|
||||
"getMempoolEntry": {},
|
||||
"getNetworkInfo": {},
|
||||
"invalidateBlock": {},
|
||||
"preciousBlock": {},
|
||||
"reconsiderBlock": {},
|
||||
"getMempoolEntry": {},
|
||||
"getNetworkInfo": {},
|
||||
}
|
||||
|
||||
// Commands that are available to a limited user
|
||||
@ -151,7 +146,6 @@ var rpcLimited = map[string]struct{}{
|
||||
"getHeaders": {},
|
||||
"getInfo": {},
|
||||
"getNetTotals": {},
|
||||
"getNetworkHashPs": {},
|
||||
"getRawMempool": {},
|
||||
"getRawTransaction": {},
|
||||
"getTxOut": {},
|
||||
|
@ -6,11 +6,12 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/kaspanet/kaspad/btcjson"
|
||||
)
|
||||
|
||||
@ -434,7 +435,6 @@ var helpDescsEnUS = map[string]string{
|
||||
"getMiningInfoResult-generate": "Whether or not server is set to generate coins",
|
||||
"getMiningInfoResult-genProcLimit": "Number of processors to use for coin generation (-1 when disabled)",
|
||||
"getMiningInfoResult-hashesPerSec": "Recent hashes per second performance measurement while generating coins",
|
||||
"getMiningInfoResult-networkHashPs": "Estimated network hashes per second for the most recent blocks",
|
||||
"getMiningInfoResult-pooledTx": "Number of transactions in the memory pool",
|
||||
"getMiningInfoResult-testNet": "Whether or not server is using testnet",
|
||||
"getMiningInfoResult-devNet": "Whether or not server is using devnet",
|
||||
@ -442,12 +442,6 @@ var helpDescsEnUS = map[string]string{
|
||||
// GetMiningInfoCmd help.
|
||||
"getMiningInfo--synopsis": "Returns a JSON object containing mining-related information.",
|
||||
|
||||
// GetNetworkHashPSCmd help.
|
||||
"getNetworkHashPs--synopsis": "Returns the estimated network hashes per second for the block heights provided by the parameters.",
|
||||
"getNetworkHashPs-blocks": "The number of blocks, or -1 for blocks since last difficulty change",
|
||||
"getNetworkHashPs-height": "Perform estimate ending with this height or -1 for current best chain block height",
|
||||
"getNetworkHashPs--result0": "Estimated hashes per second",
|
||||
|
||||
// GetNetTotalsCmd help.
|
||||
"getNetTotals--synopsis": "Returns a JSON object containing network traffic statistics.",
|
||||
|
||||
@ -689,7 +683,6 @@ var rpcResultTypes = map[string][]interface{}{
|
||||
"getMempoolInfo": {(*btcjson.GetMempoolInfoResult)(nil)},
|
||||
"getMiningInfo": {(*btcjson.GetMiningInfoResult)(nil)},
|
||||
"getNetTotals": {(*btcjson.GetNetTotalsResult)(nil)},
|
||||
"getNetworkHashPs": {(*int64)(nil)},
|
||||
"getPeerInfo": {(*[]btcjson.GetPeerInfoResult)(nil)},
|
||||
"getRawMempool": {(*[]string)(nil), (*btcjson.GetRawMempoolVerboseResult)(nil)},
|
||||
"getRawTransaction": {(*string)(nil), (*btcjson.TxRawResult)(nil)},
|
||||
|
Loading…
x
Reference in New Issue
Block a user