Support getmempoolinfo.
This commit is contained in:
parent
09ce6f94d3
commit
7cfa843832
4 changed files with 61 additions and 15 deletions
|
@ -122,6 +122,13 @@ type GetBlockTemplateResult struct {
|
||||||
RejectReasion string `json:"reject-reason,omitempty"`
|
RejectReasion string `json:"reject-reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMempoolInfoResult models the data returned from the getmempoolinfo
|
||||||
|
// command.
|
||||||
|
type GetMempoolInfoResult struct {
|
||||||
|
Size int64 `json:"size"`
|
||||||
|
Bytes int64 `json:"bytes"`
|
||||||
|
}
|
||||||
|
|
||||||
// GetNetworkInfoResult models the data returned from the getnetworkinfo
|
// GetNetworkInfoResult models the data returned from the getnetworkinfo
|
||||||
// command.
|
// command.
|
||||||
type GetNetworkInfoResult struct {
|
type GetNetworkInfoResult struct {
|
||||||
|
|
|
@ -162,21 +162,22 @@ the method name for further details such as parameter and return information.
|
||||||
|12|[getgenerate](#getgenerate)|N|Return if the server is set to generate coins (mine) or not.|
|
|12|[getgenerate](#getgenerate)|N|Return if the server is set to generate coins (mine) or not.|
|
||||||
|13|[gethashespersec](#gethashespersec)|N|Returns a recent hashes per second performance measurement while generating coins (mining).|
|
|13|[gethashespersec](#gethashespersec)|N|Returns a recent hashes per second performance measurement while generating coins (mining).|
|
||||||
|14|[getinfo](#getinfo)|Y|Returns a JSON object containing various state info.|
|
|14|[getinfo](#getinfo)|Y|Returns a JSON object containing various state info.|
|
||||||
|15|[getmininginfo](#getmininginfo)|N|Returns a JSON object containing mining-related information.|
|
|15|[getmempoolinfo](#getmempoolinfo)|N|Returns a JSON object containing mempool-related information.|
|
||||||
|16|[getnettotals](#getnettotals)|Y|Returns a JSON object containing network traffic statistics.|
|
|16|[getmininginfo](#getmininginfo)|N|Returns a JSON object containing mining-related information.|
|
||||||
|17|[getnetworkhashps](#getnetworkhashps)|Y|Returns the estimated network hashes per second for the block heights provided by the parameters.|
|
|17|[getnettotals](#getnettotals)|Y|Returns a JSON object containing network traffic statistics.|
|
||||||
|18|[getpeerinfo](#getpeerinfo)|N|Returns information about each connected network peer as an array of json objects.|
|
|18|[getnetworkhashps](#getnetworkhashps)|Y|Returns the estimated network hashes per second for the block heights provided by the parameters.|
|
||||||
|19|[getrawmempool](#getrawmempool)|Y|Returns an array of hashes for all of the transactions currently in the memory pool.|
|
|19|[getpeerinfo](#getpeerinfo)|N|Returns information about each connected network peer as an array of json objects.|
|
||||||
|20|[getrawtransaction](#getrawtransaction)|Y|Returns information about a transaction given its hash.|
|
|20|[getrawmempool](#getrawmempool)|Y|Returns an array of hashes for all of the transactions currently in the memory pool.|
|
||||||
|21|[getwork](#getwork)|N|Returns formatted hash data to work on or checks and submits solved data.<br /><font color="orange">NOTE: Since btcd does not have the wallet integrated to provide payment addresses, btcd must be configured via the `--miningaddr` option to provide which payment addresses to pay created blocks to for this RPC to function.</font>|
|
|21|[getrawtransaction](#getrawtransaction)|Y|Returns information about a transaction given its hash.|
|
||||||
|22|[help](#help)|Y|Returns a list of all commands or help for a specified command.|
|
|22|[getwork](#getwork)|N|Returns formatted hash data to work on or checks and submits solved data.<br /><font color="orange">NOTE: Since btcd does not have the wallet integrated to provide payment addresses, btcd must be configured via the `--miningaddr` option to provide which payment addresses to pay created blocks to for this RPC to function.</font>|
|
||||||
|23|[ping](#ping)|N|Queues a ping to be sent to each connected peer.|
|
|23|[help](#help)|Y|Returns a list of all commands or help for a specified command.|
|
||||||
|24|[sendrawtransaction](#sendrawtransaction)|Y|Submits the serialized, hex-encoded transaction to the local peer and relays it to the network.<br /><font color="orange">btcd does not yet implement the `allowhighfees` parameter, so it has no effect</font>|
|
|24|[ping](#ping)|N|Queues a ping to be sent to each connected peer.|
|
||||||
|25|[setgenerate](#setgenerate) |N|Set the server to generate coins (mine) or not.<br/>NOTE: Since btcd does not have the wallet integrated to provide payment addresses, btcd must be configured via the `--miningaddr` option to provide which payment addresses to pay created blocks to for this RPC to function.|
|
|25|[sendrawtransaction](#sendrawtransaction)|Y|Submits the serialized, hex-encoded transaction to the local peer and relays it to the network.<br /><font color="orange">btcd does not yet implement the `allowhighfees` parameter, so it has no effect</font>|
|
||||||
|26|[stop](#stop)|N|Shutdown btcd.|
|
|26|[setgenerate](#setgenerate) |N|Set the server to generate coins (mine) or not.<br/>NOTE: Since btcd does not have the wallet integrated to provide payment addresses, btcd must be configured via the `--miningaddr` option to provide which payment addresses to pay created blocks to for this RPC to function.|
|
||||||
|27|[submitblock](#submitblock)|Y|Attempts to submit a new serialized, hex-encoded block to the network.|
|
|27|[stop](#stop)|N|Shutdown btcd.|
|
||||||
|28|[validateaddress](#validateaddress)|Y|Verifies the given address is valid. NOTE: Since btcd does not have a wallet integrated, btcd will only return whether the address is valid or not.|
|
|28|[submitblock](#submitblock)|Y|Attempts to submit a new serialized, hex-encoded block to the network.|
|
||||||
|29|[verifychain](#verifychain)|N|Verifies the block chain database.|
|
|29|[validateaddress](#validateaddress)|Y|Verifies the given address is valid. NOTE: Since btcd does not have a wallet integrated, btcd will only return whether the address is valid or not.|
|
||||||
|
|30|[verifychain](#verifychain)|N|Verifies the block chain database.|
|
||||||
|
|
||||||
<a name="MethodDetails" />
|
<a name="MethodDetails" />
|
||||||
**5.2 Method Details**<br />
|
**5.2 Method Details**<br />
|
||||||
|
@ -352,6 +353,18 @@ the method name for further details such as parameter and return information.
|
||||||
|Example Return|`{`<br /> `"version": 70000`<br /> `"protocolversion": 70001, `<br /> `"blocks": 298963,`<br /> `"timeoffset": 0,`<br /> `"connections": 17,`<br /> `"proxy": "",`<br /> `"difficulty": 8000872135.97,`<br /> `"testnet": false,`<br /> `"relayfee": 0.00001,`<br />`}`|
|
|Example Return|`{`<br /> `"version": 70000`<br /> `"protocolversion": 70001, `<br /> `"blocks": 298963,`<br /> `"timeoffset": 0,`<br /> `"connections": 17,`<br /> `"proxy": "",`<br /> `"difficulty": 8000872135.97,`<br /> `"testnet": false,`<br /> `"relayfee": 0.00001,`<br />`}`|
|
||||||
[Return to Overview](#MethodOverview)<br />
|
[Return to Overview](#MethodOverview)<br />
|
||||||
|
|
||||||
|
***
|
||||||
|
<a name="getmempoolinfo"/>
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
|Method|getmempoolinfo|
|
||||||
|
|Parameters|None|
|
||||||
|
|Description|Returns a JSON object containing mempool-related information.|
|
||||||
|
|Returns|`{ (json object)`<br /> `"bytes": n, (numeric) size in bytes of the mempool`<br /> `"size": n, (numeric) number of transactions in the mempool`<br />`}`|
|
||||||
|
Example Return|`{`<br /> `"bytes": 310768,`<br /> `"size": 157,`<br />`}`|
|
||||||
|
[Return to Overview](#MethodOverview)<br />
|
||||||
|
|
||||||
***
|
***
|
||||||
<a name="getmininginfo"/>
|
<a name="getmininginfo"/>
|
||||||
|
|
||||||
|
|
18
rpcserver.go
18
rpcserver.go
|
@ -146,6 +146,7 @@ var rpcHandlersBeforeInit = map[string]commandHandler{
|
||||||
"getgenerate": handleGetGenerate,
|
"getgenerate": handleGetGenerate,
|
||||||
"gethashespersec": handleGetHashesPerSec,
|
"gethashespersec": handleGetHashesPerSec,
|
||||||
"getinfo": handleGetInfo,
|
"getinfo": handleGetInfo,
|
||||||
|
"getmempoolinfo": handleGetMempoolInfo,
|
||||||
"getmininginfo": handleGetMiningInfo,
|
"getmininginfo": handleGetMiningInfo,
|
||||||
"getnettotals": handleGetNetTotals,
|
"getnettotals": handleGetNetTotals,
|
||||||
"getnetworkhashps": handleGetNetworkHashPS,
|
"getnetworkhashps": handleGetNetworkHashPS,
|
||||||
|
@ -1938,6 +1939,23 @@ func handleGetInfo(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (in
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleGetMempoolInfo implements the getmempoolinfo command.
|
||||||
|
func handleGetMempoolInfo(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
||||||
|
txD := s.server.txMemPool.TxDescs()
|
||||||
|
|
||||||
|
var numBytes int64
|
||||||
|
for _, desc := range txD {
|
||||||
|
numBytes += int64(desc.Tx.MsgTx().SerializeSize())
|
||||||
|
}
|
||||||
|
|
||||||
|
ret := &btcjson.GetMempoolInfoResult{
|
||||||
|
Size: int64(len(txD)),
|
||||||
|
Bytes: numBytes,
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
|
|
||||||
// handleGetMiningInfo implements the getmininginfo command. We only return the
|
// handleGetMiningInfo implements the getmininginfo command. We only return the
|
||||||
// fields that are not related to wallet functionality.
|
// fields that are not related to wallet functionality.
|
||||||
func handleGetMiningInfo(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
func handleGetMiningInfo(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
||||||
|
|
|
@ -288,6 +288,13 @@ var helpDescsEnUS = map[string]string{
|
||||||
// GetInfoCmd help.
|
// GetInfoCmd help.
|
||||||
"getinfo--synopsis": "Returns a JSON object containing various state info.",
|
"getinfo--synopsis": "Returns a JSON object containing various state info.",
|
||||||
|
|
||||||
|
// GetMempoolInfoCmd help.
|
||||||
|
"getmempoolinfo--synopsis": "Returns memory pool information",
|
||||||
|
|
||||||
|
// GetMempoolInfoResult help.
|
||||||
|
"getmempoolinforesult-bytes": "Size in bytes of the mempool",
|
||||||
|
"getmempoolinforesult-size": "Number of transactions in the mempool",
|
||||||
|
|
||||||
// GetMiningInfoResult help.
|
// GetMiningInfoResult help.
|
||||||
"getmininginforesult-blocks": "Height of the latest best block",
|
"getmininginforesult-blocks": "Height of the latest best block",
|
||||||
"getmininginforesult-currentblocksize": "Size of the latest best block",
|
"getmininginforesult-currentblocksize": "Size of the latest best block",
|
||||||
|
@ -540,6 +547,7 @@ var rpcResultTypes = map[string][]interface{}{
|
||||||
"getgenerate": []interface{}{(*bool)(nil)},
|
"getgenerate": []interface{}{(*bool)(nil)},
|
||||||
"gethashespersec": []interface{}{(*float64)(nil)},
|
"gethashespersec": []interface{}{(*float64)(nil)},
|
||||||
"getinfo": []interface{}{(*btcjson.InfoChainResult)(nil)},
|
"getinfo": []interface{}{(*btcjson.InfoChainResult)(nil)},
|
||||||
|
"getmempoolinfo": []interface{}{(*btcjson.GetMempoolInfoResult)(nil)},
|
||||||
"getmininginfo": []interface{}{(*btcjson.GetMiningInfoResult)(nil)},
|
"getmininginfo": []interface{}{(*btcjson.GetMiningInfoResult)(nil)},
|
||||||
"getnettotals": []interface{}{(*btcjson.GetNetTotalsResult)(nil)},
|
"getnettotals": []interface{}{(*btcjson.GetNetTotalsResult)(nil)},
|
||||||
"getnetworkhashps": []interface{}{(*int64)(nil)},
|
"getnetworkhashps": []interface{}{(*int64)(nil)},
|
||||||
|
|
Loading…
Reference in a new issue