コード例 #1
0
ファイル: kad_session.py プロジェクト: jeromeetienne/neoip
	def	findsomeval_rpc( self, keyid, max_nb_record, dest_naddr, opttl = kad_delay( 30 ) ):
		'''Perform a FINDSOMEVAL rpc to dest_naddr
		
			It may return 2 kind of results:
				- if the destination node has records matching this keyid, it return
				  a list of 2 elements
				  - Element 1 is bool equal to True, the destination node has more records matching
				    this keyid
				  - Element 2 is a list of the found kad_rec
				- if the destination node has no records matching this keyid, it return
				  a list of 2 elements
				  - Element 1 is a string equal to a cookie_id
				  - Element 2 is a list of the nclosest node to the keyid
		'''
		# sanity check - check the parameters type
		assert isinstance( keyid		, kad_id )
		assert isinstance( max_nb_record, int )
		assert isinstance( dest_naddr	, kad_naddr )
		assert isinstance( opttl		, kad_delay )
		# send the rpc itself
		result = self.rpcserver.dht.findsomeval_rpc( keyid.to_xmlrpc(), str( max_nb_record ), self.sessid, opttl.to_xmlrpc() )
		if isinstance(result[0], bool):
			# if it is a recdups
			return [result[0], [kad_rec.from_xmlrpc( i ) for i in result[1]]]			
		else:
			# if it is a naddrlist
			return [result[0], [kad_naddr.from_xmlrpc( i ) for i in result[1]]]	
コード例 #2
0
ファイル: kad_session.py プロジェクト: jeromeetienne/neoip
	def getall( self, keyid, max_nb_record = 1, opttl = kad_delay( 30 ) ):
		'''Get all records on this session

			Dont return more than max_nb_record

			It return a list of 2 elements
			  - Element 1 is bool equal to True, the destination node has more records matching
			    this keyid
			  - Element 2 is a list of the found kad_rec
		'''
		# sanity check - check the parameters type
		assert isinstance( keyid	, kad_id )
		assert isinstance( opttl	, kad_delay )
		# send the rpc itself
		result = self.rpcserver.dht.getall( keyid.to_xmlrpc(), str( max_nb_record ), self.sessid, opttl.to_xmlrpc() )
		# convert the result and return it
		return [result[0], [kad_rec.from_xmlrpc( i ) for i in result[1]]]			
コード例 #3
0
ファイル: kad_session.py プロジェクト: jeromeetienne/neoip
	def	findallval_rpc( self, recid, keyid, keyid_ge, max_nb_record, dest_naddr, opttl = kad_delay( 30 ) ):
		'''Perform a FINDALLVAL rpc to dest_naddr

			It return a list of 2 elements
			  - Element 1 is bool equal to True, the destination node has more records matching
			    this keyid
			  - Element 2 is a list of the found kad_rec
		'''
		# sanity check - check the parameters type
		assert isinstance( recid		, kad_id )
		assert isinstance( keyid		, kad_id )
		assert isinstance( keyid_ge		, bool )
		assert isinstance( max_nb_record, int )
		assert isinstance( dest_naddr	, kad_naddr )
		assert isinstance( opttl		, kad_delay )
		# send the rpc itself
		result = self.rpcserver.dht.findsomeval_rpc( recid.to_xmlrpc(), keyid.to_xmlrpc(), keyid_ge
												, str( max_nb_record ), self.sessid, opttl.to_xmlrpc() )
		# convert the result
		return [result[0], [kad_rec.from_xmlrpc( i ) for i in result[1]]]