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:
parent
a9e1b8fb84
commit
cb67972512
1 changed files with 6 additions and 1 deletions
|
@ -369,11 +369,16 @@ type FutureSubmitBlockResult chan *response
|
||||||
// Receive waits for the response promised by the future and returns an error if
|
// Receive waits for the response promised by the future and returns an error if
|
||||||
// any occurred when submitting the block.
|
// any occurred when submitting the block.
|
||||||
func (r FutureSubmitBlockResult) Receive() error {
|
func (r FutureSubmitBlockResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
res, err := receiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resStr := string(res)
|
||||||
|
if resStr != "null" {
|
||||||
|
return errors.New(resStr)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue