Improve getwork interaction with regtest mode.
Ordinarily, getwork will return an error if btcd is not connected to any other peers. This commit relaxes that requirement when running in regression test mode since it is useful for development purposes. While here, also improve check which returns an error from getwork is not current to exclude the check when the best chain height is zero since the code never believes it is current when at height 0.
This commit is contained in:
parent
47e65634a7
commit
6a325f4c6a
1 changed files with 4 additions and 2 deletions
|
@ -1749,12 +1749,14 @@ func handleGetWork(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
|
|||
|
||||
// Return an error if there are no peers connected since there is no
|
||||
// way to relay a found block or receive transactions to work on.
|
||||
if s.server.ConnectedCount() == 0 {
|
||||
// However, allow this state when running in regression test mode.
|
||||
if !cfg.RegressionTest && s.server.ConnectedCount() == 0 {
|
||||
return nil, btcjson.ErrClientNotConnected
|
||||
}
|
||||
|
||||
// No point in generating or accepting work before the chain is synced.
|
||||
if !s.server.blockManager.IsCurrent() {
|
||||
_, currentHeight := s.server.blockManager.chainState.Best()
|
||||
if currentHeight != 0 && !s.server.blockManager.IsCurrent() {
|
||||
return nil, btcjson.ErrClientInInitialDownload
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue