[NOD-296] Send SyncMgr.SubmitBlock errors as rpc errors (#381)

* [NOD-296] Send SyncMgr.SubmitBlock errors as rpc errors

* [NOD-296] Add error message prefix
This commit is contained in:
Ori Newman 2019-08-27 11:25:45 +03:00 committed by stasatdaglabs
parent 552a5917c2
commit 5cf7f01d3f

View File

@ -3537,7 +3537,10 @@ func handleSubmitBlock(s *Server, cmd interface{}, closeChan <-chan struct{}) (i
// nodes. This will in turn relay it to the network like normal.
_, err = s.cfg.SyncMgr.SubmitBlock(block, blockdag.BFNone)
if err != nil {
return fmt.Sprintf("rejected: %s", err.Error()), nil
return nil, &btcjson.RPCError{
Code: btcjson.ErrRPCVerify,
Message: fmt.Sprintf("Block rejected. Reason: %s", err),
}
}
log.Infof("Accepted block %s via submitBlock", block.Hash())