rpcserver: Use default values for getnetworkhashps.
When the fields in the command for the getnetworkhashps RPC don't have the fields set, use the intended default values. Since the btcjson package sets these fields to the default values when a command is unmarshaled from the wire, this typically isn't necessary. However, when the RPC server calls the handler internally with optional command fields set to nil, as is the case in getmininginfo, the defaults need to be set as well.
This commit is contained in:
parent
5ac0f1247d
commit
28269d2598
1 changed files with 2 additions and 2 deletions
|
@ -1832,7 +1832,7 @@ func handleGetNetworkHashPS(s *rpcServer, cmd interface{}, closeChan <-chan stru
|
||||||
// since we can't reasonably calculate the number of network hashes
|
// since we can't reasonably calculate the number of network hashes
|
||||||
// per second from invalid values. When it's negative, use the current
|
// per second from invalid values. When it's negative, use the current
|
||||||
// best block height.
|
// best block height.
|
||||||
var endHeight int64
|
endHeight := int64(-1)
|
||||||
if c.Height != nil {
|
if c.Height != nil {
|
||||||
endHeight = int64(*c.Height)
|
endHeight = int64(*c.Height)
|
||||||
}
|
}
|
||||||
|
@ -1847,7 +1847,7 @@ func handleGetNetworkHashPS(s *rpcServer, cmd interface{}, closeChan <-chan stru
|
||||||
// blocks. When the passed value is negative, use the last block the
|
// blocks. When the passed value is negative, use the last block the
|
||||||
// difficulty changed as the starting height. Also make sure the
|
// difficulty changed as the starting height. Also make sure the
|
||||||
// starting height is not before the beginning of the chain.
|
// starting height is not before the beginning of the chain.
|
||||||
var numBlocks int64
|
numBlocks := int64(120)
|
||||||
if c.Blocks != nil {
|
if c.Blocks != nil {
|
||||||
numBlocks = int64(*c.Blocks)
|
numBlocks = int64(*c.Blocks)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue