rpcclient: always return tx hash from sendrawtransaction
Let upper-layer APIs like actor.Send() return it as well. Server can return "already exists" which is an error and yet at the same time a very special one, in many cases it means we can proceed with waiting for the TX to settle.
This commit is contained in:
parent
0039615ae3
commit
c95d140113
1 changed files with 4 additions and 5 deletions
|
@ -692,17 +692,16 @@ func (c *Client) invokeSomething(method string, p []interface{}, signers []trans
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendRawTransaction broadcasts a transaction over the NEO network.
|
// SendRawTransaction broadcasts the given transaction to the Neo network.
|
||||||
// The given hex string needs to be signed with a keypair.
|
// It always returns transaction hash, when successful (no error) this is the
|
||||||
// When the result of the response object is true, the TX has successfully
|
// hash returned from server, when not it's a locally calculated rawTX hash.
|
||||||
// been broadcasted to the network.
|
|
||||||
func (c *Client) SendRawTransaction(rawTX *transaction.Transaction) (util.Uint256, error) {
|
func (c *Client) SendRawTransaction(rawTX *transaction.Transaction) (util.Uint256, error) {
|
||||||
var (
|
var (
|
||||||
params = []interface{}{rawTX.Bytes()}
|
params = []interface{}{rawTX.Bytes()}
|
||||||
resp = new(result.RelayResult)
|
resp = new(result.RelayResult)
|
||||||
)
|
)
|
||||||
if err := c.performRequest("sendrawtransaction", params, resp); err != nil {
|
if err := c.performRequest("sendrawtransaction", params, resp); err != nil {
|
||||||
return util.Uint256{}, err
|
return rawTX.Hash(), err
|
||||||
}
|
}
|
||||||
return resp.Hash, nil
|
return resp.Hash, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue