[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mojonation-devel
Subject:    [Mojonation-devel] CVS: evil/common idclosenesslib.py,NONE,1.1 BlockServerHandicapper.py,1.10,1.11
From:       "Gregory P. Smith" <greg () users ! sourceforge ! net>
Date:       2001-06-29 22:13:06
[Download RAW message or body]

Update of /cvsroot/mojonation/evil/common
In directory usw-pr-cvs1:/tmp/cvs-serv10334/common

Modified Files:
	BlockServerHandicapper.py 
Added Files:
	idclosenesslib.py 
Log Message:
moving common code into a lib.



diff -d -u -r1.10 -r1.11
--- BlockServerHandicapper.py	2001/06/28 14:32:27	1.10
+++ BlockServerHandicapper.py	2001/06/29 22:13:04	1.11
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-#  Copyright (c) 2000 Autonomous Zone Industries
+#  Copyright (c) 2001 Autonomous Zone Industries
 #  This file is licensed under the
 #    GNU Lesser General Public License v2.1.
 #    See the file COPYING or visit http://www.gnu.org/ for details.
@@ -22,6 +22,7 @@
 from human_readable import hr
 import idlib
 import idmasklib
+import idclosenesslib
 import mojosixbit
 import mojoutil
 
@@ -43,36 +44,12 @@
     assert blockid is not None, "message_body must contain a `blob id'.  \
counterparty_id: %s, metainfo: %s, message_type: %s, message_body: %s" % \
(hr(counterparty_id), hr(metainfo), hr(message_type), hr(message_body),)  blockid = \
idlib.canonicalize(blockid)  
-    mask = None
-    stddev = None
-    bits = None
-    for service in metainfo.get('services', ()):
-        if (service is not None) and (service.get('type') == 'blob server'):
-            maskentry = service.get('mask list')[0]
-            mask = maskentry.get('mask')
-            try:
-                # try to un-ascii-fy it.
-                mask = mojosixbit.a2b(mask)
-            except mojosixbit.Error:
-                pass
-
-            mask = mask + counterparty_id[len(mask):]
-
-            stddev = maskentry.get('stddev')
-            bits = mojoutil.intorlongpopL(maskentry.get('bits', 8))
-
-            assert len(mask) == MojoConstants.SIZE_OF_UNIQS, "mask: %s" % hr(mask)
-
-    if bits is None:
-        debug.mojolog.write("Warning: I was asked to do hash closeness handicapping, \
but the metainfo does not include a mask list at all.  counterparty_id: %s, metainfo: \
%s, message_type: %s, message_body: %s\n", args=(counterparty_id, metainfo, \
                message_type, message_body,), v=0, vs="debug")
-        return 0 # ???
+    try:
+        mask, stddev = get_blobserver_centerid_and_stddev(counterparty_id, metainfo)
+    except idclosenesslib.Error, e:
+        debug.mojolog.write("Warning: got error %s during hash closeness \
handicapping, message_type: %s, message_body: %s\n", args=(e, message_type, \
message_body,), v=0, vs="BlockServerHandicapper") +        return 3*TUNING_FACTOR  # \
make it seem far away on an error ???  (way may just want to let MojoHandicapper \
catch this and deal)  
-    if stddev is None:
-        # Make `stddev' be one-half of the size of their mask-included blockspace.
-        stddev = 2L ** ((24 - bits) - 1)
-    else:
-        stddev = mojoutil.intorlongpopL(stddev)
-        
     # Their handicap is the number of standard deviations away times the \
                TUNING_FACTOR.
     dist = abs(idlib.id_to_native_int(mask) - idlib.id_to_native_int(blockid))
 


_______________________________________________
Mojonation-devel mailing list
Mojonation-devel@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mojonation-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic