MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / callRPC

Method callRPC

src/namecoin.py:172–194  ·  view source on GitHub ↗
(self, method, params)

Source from the content-addressed store, hash-verified

170
171 # Helper routine that actually performs an JSON RPC call.
172 def callRPC (self, method, params):
173 data = {"method": method, "params": params, "id": self.queryid}
174 if self.nmctype == "namecoind":
175 resp = self.queryHTTP (json.dumps (data))
176 elif self.nmctype == "nmcontrol":
177 resp = self.queryServer (json.dumps (data))
178 else:
179 assert False
180 val = json.loads (resp)
181
182 if val["id"] != self.queryid:
183 raise Exception ("ID mismatch in JSON RPC answer.")
184
185 if self.nmctype == "namecoind":
186 self.queryid = self.queryid + 1
187
188 error = val["error"]
189 if error is None:
190 return val["result"]
191
192 if isinstance(error, bool):
193 raise RPCError (val["result"])
194 raise RPCError (error)
195
196 # Query the server via HTTP.
197 def queryHTTP (self, data):

Callers 2

queryMethod · 0.95
testMethod · 0.95

Calls 3

queryHTTPMethod · 0.95
queryServerMethod · 0.95
RPCErrorClass · 0.85

Tested by

no test coverage detected