Detect error strings on SumitBlock.

The submitblock RPC returns a string containing an error if it failed for
any reason.  This comment detects a non-null return from submitblock and
converts that string to an error which is returned.
This commit is contained in:
Dave Collins 2014-06-26 18:04:01 -05:00
parent a9e1b8fb84
commit cb67972512

View file

@ -369,11 +369,16 @@ type FutureSubmitBlockResult chan *response
// Receive waits for the response promised by the future and returns an error if
// any occurred when submitting the block.
func (r FutureSubmitBlockResult) Receive() error {
_, err := receiveFuture(r)
res, err := receiveFuture(r)
if err != nil {
return err
}
resStr := string(res)
if resStr != "null" {
return errors.New(resStr)
}
return nil
}