From 6a325f4c6a8dacc823a460ba8069105f8f98a26f Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Thu, 8 May 2014 19:46:56 -0500 Subject: [PATCH] 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. --- rpcserver.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 2cdd262ee..b272756d8 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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 }