Previously it was a dictionary, whose key 'rsp' contained the response dictionary.
The response dictionary has a key '_krpc_sender' added.
self.outstanding -= 1
self.outstanding_results -= expected_results
self.answered[node.id] = 1
- self.processResponse(dict['rsp'])
+ self.processResponse(dict)
self.schedule()
def actionFailed(self, err, node, expected_results):
def _notStaleNodeHandler(dict, old=old, self=self):
"""Got a pong from the old node, so update it."""
- dict = dict['rsp']
if dict['id'] == old.id:
self.table.justSeenNode(old.id)
def _pongHandler(dict, node=node, self=self, callback=callback):
"""Node responded properly, callback with response."""
- n = self.Node(dict['rsp']['id'], dict['_krpc_sender'][0], dict['_krpc_sender'][1])
+ n = self.Node(dict['id'], dict['_krpc_sender'][0], dict['_krpc_sender'][1])
self.insertNode(n)
if callback:
- callback((dict['rsp']['ip_addr'], dict['rsp']['port']))
+ callback((dict['ip_addr'], dict['port']))
def _defaultPong(err, node=node, self=self, callback=callback, errback=errback):
"""Error occurred, fail node and errback or callback with error."""
def checkSender(self, dict):
"""Check the sender's info to make sure it meets expectations."""
try:
- senderid = dict['rsp']['id']
+ senderid = dict['id']
except KeyError:
log.msg("No peer id in response")
raise Exception, "No peer id in response."
df = self.tids[msg[TID]]
# callback
del(self.tids[msg[TID]])
- df.callback({'rsp' : msg[RSP], '_krpc_sender': addr})
+ msg[RSP]['_krpc_sender'] = addr
+ df.callback(msg[RSP])
else:
# no tid, this transaction timed out already...
if self.noisy:
return {'values': ['1'*length]*num}
def make(port):
+ from stats import StatsLogger
af = Receiver()
- a = hostbroker(af, {'SPEW': False})
+ a = hostbroker(af, StatsLogger(None, None, {}), {'SPEW': False})
a.protocol = KRPC
p = reactor.listenUDP(port, a)
return af, a, p
def gotMsg(self, dict, should_be):
_krpc_sender = dict['_krpc_sender']
- msg = dict['rsp']
- self.failUnlessEqual(msg['msg'], should_be)
+ self.failUnlessEqual(dict['msg'], should_be)
def testManyEcho(self):
for i in xrange(100):