def PutKey( self, rsaKey, data, updateLevel ) : self._initCount() signature = computeSignature( rsaKey, data, updateLevel ) self.client.callPutKey( rsaKey.toDER_PublicKey(), data, updateLevel, signature, self.nodeAddr, self._onResult ) self.reactor.run()
def onResult(nodes): obj.nodes = nodes obj.successCount = 0 obj.putOps = {} obj.updateLevel = updateLevel + 1 obj.signature = computeSignature(rsaKey, data, obj.updateLevel) for nodeAddr in obj.nodes: doPutKey(nodeAddr) op.setCanceler(cancelPuts) if not obj.putOps: doNotify()
def onResult( nodes ) : obj.nodes = nodes obj.successCount = 0 obj.putOps = {} obj.updateLevel = updateLevel + 1 obj.signature = computeSignature( rsaKey, data, obj.updateLevel ) for nodeAddr in obj.nodes : doPutKey( nodeAddr ) op.setCanceler( cancelPuts ) if not obj.putOps : doNotify()
def onPut(putOp, err, payload): del obj.putOps[putOp] if err >= 0: result, oldData, oldUpdateLevel, oldSignature = payload if result >= 0: obj.successCount += 1 elif oldUpdateLevel >= obj.updateLevel: if verifySignature(rsaKey, oldData, oldUpdateLevel, oldSignature): obj.updateLevel = oldUpdateLevel + 1 cancelPuts() obj.putOps.clear() obj.successCount = 0 obj.signature = computeSignature(rsaKey, data, obj.updateLevel) for nodeAddr in obj.nodes: doPutKey(nodeAddr) if not obj.putOps: doNotify()
def onPut( putOp, err, payload ) : del obj.putOps[putOp] if err >= 0 : result,oldData,oldUpdateLevel,oldSignature = payload if result >= 0 : obj.successCount += 1 elif oldUpdateLevel >= obj.updateLevel : if verifySignature(rsaKey,oldData, oldUpdateLevel,oldSignature) : obj.updateLevel = oldUpdateLevel + 1 cancelPuts() obj.putOps.clear() obj.successCount = 0 obj.signature = computeSignature( rsaKey, data, obj.updateLevel ) for nodeAddr in obj.nodes : doPutKey( nodeAddr ) if not obj.putOps : doNotify()
def PutKey(self, rsaKey, data, updateLevel): self._initCount() signature = computeSignature(rsaKey, data, updateLevel) self.client.callPutKey(rsaKey.toDER_PublicKey(), data, updateLevel, signature, self.nodeAddr, self._onResult) self.reactor.run()