SF.net SVN: fclient: [434] trunk/sandbox/fcp2/message.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-06-30 08:58:05
|
Revision: 434
http://fclient.svn.sourceforge.net/fclient/?rev=434&view=rev
Author: jUrner
Date: 2008-06-30 01:57:58 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
removed some leftover code
++ beautifications
Modified Paths:
--------------
trunk/sandbox/fcp2/message.py
Modified: trunk/sandbox/fcp2/message.py
===================================================================
--- trunk/sandbox/fcp2/message.py 2008-06-30 08:57:07 UTC (rev 433)
+++ trunk/sandbox/fcp2/message.py 2008-06-30 08:57:58 UTC (rev 434)
@@ -218,7 +218,7 @@
# param types for config message
#
# ..bit more efford here, cos we need types for user input checking
-# ...a slpoppy implementation of a dict should be enough
+# ...a sloppy implementation of a dict should be enough
#
#***************************************************************************************
class _ConfigMessageParamTypes(object):
@@ -415,8 +415,12 @@
raise ValueError('Unknown param class in: %r' % paramName)
ConfigMessageParamTypes = _ConfigMessageParamTypes()
+
#********************************************************************************
-# equipment for messages with persustent params and additional params
+# equipp Get / Put messages with some persistent params
+#
+# these params are stored in ClientToken
+#
#********************************************************************************
class PeristentParamsGet(pmstruct.PoorMansStruct):
_fields_ = (
@@ -427,62 +431,13 @@
PeristentParamsPut = PeristentParamsGet
-
-class PersistentParams(object):
-
- def __init__(self, mapping):
- self.mapping = mapping
-
- def fromString(self, string):
- pass
-
-
-
-PeerMessageParamTypes = {
- 'ark.number': types.FcpTypeInt,
- 'auth.negTypes': types.FcpTypeInt,
-
- 'location': types.FcpTypeFloat,
- 'opennet': types.FcpTypeBool,
- 'testnet': types.FcpTypeBool,
-
- 'metadata.timeLastConnected': types.FcpTypeTime,
- 'metadata.timeLastReceivedPacket': types.FcpTypeTime,
- 'metadata.timeLastRoutable': types.FcpTypeTime,
- 'metadata.timeLastSuccess': types.FcpTypeTime,
- 'metadata.routableConnectionCheckCount': types.FcpTypeInt,
- 'metadata.hadRoutableConnectionCount': types.FcpTypeInt,
-
- 'volatile.averagePingTime': types.FcpTypeFloat,
- 'volatile.overloadProbability': types.FcpTypePercent,
- 'volatile.routingBackoff': types.FcpTypeInt,
- 'volatile.routingBackoffPercent': types.FcpTypePercent,
- 'volatile.totalBytesIn': types.FcpTypeInt,
- 'volatile.totalBytesOut': types.FcpTypeInt,
- 'volatile.routingBackoffLength': types.FcpTypeInt,
- }
-
-'''all other Peer message params here....
-
->> identity=YIrE..................
->> lastGoodVersion=Fred,0.7,1.0,1106
->> physical.udp=00.000.000.000:00000
->> version=Fred,0.7,1.0,1107
->> dsaGroup.q=ALFDN...............
->> dsaGroup.p=AIYIrE..................
->> dsaPubKey.y=YSlb............
->> dsaGroup.g=UaRa...............
->> ark.pubURI=SSK@......................
->>
->> metadata.detected.udp=000.000.000.000:00000
-
->> volatile.lastRoutingBackoffReason=ForwardRejectedOverload
->> volatile.percentTimeRoutableConnection=99.4735.................
->> volatile.status=CONNECTED
-
-'''
-
-
+#********************************************************************************
+# at runtime we store a few additional params in msg.params
+#
+# for uniformity reasons we store them in msg.params and mark them
+# as private so they don't get send to the node
+#
+#********************************************************************************
AdditionalGetParams = {
# persistent params that will go into identifier
@@ -496,12 +451,8 @@
PrivateParam('ErrorMessage'): None, # error message in case an error occured
PrivateParam('UserData'): None, # any user defined runtime data here
- # params for SSKKeypair
- PrivateParam('PrivateParamKey'): None,
- PrivateParam('PublicKey'): None,
-
# params from DataFound
- PrivateParam('MetadataContentType'): '', # contecnt type
+ PrivateParam('MetadataContentType'): '', # content type
PrivateParam('MetadataSize'): 0, # content size
# params from PersistentRequestModified
@@ -533,10 +484,6 @@
PrivateParam('ErrorMessage'): None, # error message in case an error occured
PrivateParam('UserData'): None, # any user defined runtime data here
- # params for SSKKeypair
- PrivateParam('PrivateParamKey'): None,
- PrivateParam('PublicKey'): None,
-
# params from DataFound
PrivateParam('MetadataContentType'): '', # contecnt type
PrivateParam('MetadataSize'): 0, # content size
@@ -559,8 +506,6 @@
PrivateParam('RequestType'): consts.RequestType.Null, # identifies sub message types
PrivateParam('RequestStatus'): consts.RequestStatus.Null,
PrivateParam('InitTime'): 0, # when was the request started?
- PrivateParam('PrivateKey'): None,
- PrivateParam('PublicKey'): None,
}
AdditionalSubscribeUSKParams = {
@@ -614,7 +559,7 @@
#********************************************************************************
#
#********************************************************************************
-#TODO: register new message type?
+#TODO: do we need this?
def newMessageType(name, paramTypes=None, additionalParams=None, persistentParams=None):
kws = {
'name': name,
@@ -624,11 +569,8 @@
}
return type(name, (MessageBase, ), kws)
-
-#TODO: _persistent_params_ ...define in all message classes or not? Bogus for most,
-# but makes customization of individual classes harder for useres
#********************************************************************************
-# some additional messages we define for uniformity
+# some messages defined by the client
#********************************************************************************
class ClientDisconnected(MessageBase):
name = consts.Message.ClientDisconnected
@@ -651,12 +593,54 @@
}
#********************************************************************************
-#
+# fcp messages
#********************************************************************************
class AddPeer(MessageBase):
name = consts.Message.AddPeer
_additional_params_ = {}
- _param_types_ = PeerMessageParamTypes
+ _param_types_ = {
+ 'ark.number': types.FcpTypeInt,
+ 'auth.negTypes': types.FcpTypeInt,
+ 'ark.pubURI': key.FcpTypeKey,
+
+ 'location': types.FcpTypeFloat,
+ 'opennet': types.FcpTypeBool,
+ 'testnet': types.FcpTypeBool,
+
+ # passed in Peer message
+ 'metadata.timeLastConnected': types.FcpTypeTime,
+ 'metadata.timeLastReceivedPacket': types.FcpTypeTime,
+ 'metadata.timeLastRoutable': types.FcpTypeTime,
+ 'metadata.timeLastSuccess': types.FcpTypeTime,
+ 'metadata.routableConnectionCheckCount': types.FcpTypeInt,
+ 'metadata.hadRoutableConnectionCount': types.FcpTypeInt,
+
+ 'volatile.averagePingTime': types.FcpTypeFloat,
+ 'volatile.overloadProbability': types.FcpTypePercent,
+ 'volatile.routingBackoff': types.FcpTypeInt,
+ 'volatile.routingBackoffPercent': types.FcpTypePercent,
+ 'volatile.totalBytesIn': types.FcpTypeInt,
+ 'volatile.totalBytesOut': types.FcpTypeInt,
+ 'volatile.routingBackoffLength': types.FcpTypeInt,
+ }
+
+'''all other Peer message params here....
+
+>> identity=YIrE..................
+>> lastGoodVersion=Fred,0.7,1.0,1106
+>> physical.udp=00.000.000.000:00000
+>> version=Fred,0.7,1.0,1107
+>> dsaGroup.q=ALFDN...............
+>> dsaGroup.p=AIYIrE..................
+>> dsaPubKey.y=YSlb............
+>> dsaGroup.g=UaRa...............
+>>
+>> metadata.detected.udp=000.000.000.000:00000
+
+>> volatile.lastRoutingBackoffReason=ForwardRejectedOverload
+>> volatile.percentTimeRoutableConnection=99.4735.................
+>> volatile.status=CONNECTED
+'''
class AllData(MessageBase):
@@ -1103,7 +1087,7 @@
class Peer(MessageBase):
name = consts.Message.Peer
_additional_params_ = {}
- _param_types_ = PeerMessageParamTypes
+ _param_types_ = AddPeer._param_types_
class PeerNote(MessageBase):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|