Commit f2def43a authored by Iustin Pop's avatar Iustin Pop
Browse files

RpcResult: add a new payload field

For results which use the (status, payload) response type, it's easier
to define a ‘payload’ field on the result holding the payload than to
extract it using “data[1]” in the caller code.

Reviewed-by: ultrotter
parent 4978db17
......@@ -104,13 +104,17 @@ class RpcResult(object):
if offline:
self.failed = True
self.error = "Node is marked offline"
self.data = None
self.data = self.payload = None
elif failed:
self.error = data
self.data = None
self.data = self.payload = None
else:
self.data = data
self.error = None
if isinstance(data, (tuple, list)) and len(data) == 2:
self.payload = data[1]
else:
self.payload = None
def Raise(self):
"""If the result has failed, raise an OpExecError.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment