mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-30 01:38:55 +00:00
add RIClient.get_versions, in the hopes of enabling backwards-compatibility code in the future
This commit is contained in:
parent
7862dc5747
commit
5ceeaaea6a
@ -7,6 +7,7 @@ from allmydata import node
|
||||
|
||||
from twisted.internet import defer
|
||||
|
||||
import allmydata
|
||||
from allmydata.Crypto.Util.number import bytes_to_long
|
||||
from allmydata.storageserver import StorageServer
|
||||
from allmydata.upload import Uploader
|
||||
@ -26,6 +27,9 @@ class Client(node.Node, Referenceable):
|
||||
INTRODUCER_FURL_FILE = "introducer.furl"
|
||||
GLOBAL_VDRIVE_FURL_FILE = "vdrive.furl"
|
||||
|
||||
# we're pretty narrow-minded right now
|
||||
OLDEST_SUPPORTED_VERSION = allmydata.__version__
|
||||
|
||||
def __init__(self, basedir="."):
|
||||
node.Node.__init__(self, basedir)
|
||||
self.my_pburl = None
|
||||
@ -87,6 +91,9 @@ class Client(node.Node, Referenceable):
|
||||
self.connected_to_vdrive = False
|
||||
vdrive_root.notifyOnDisconnect(_disconnected)
|
||||
|
||||
def remote_get_versions(self):
|
||||
return str(allmydata.__version__), str(self.OLDEST_SUPPORTED_VERSION)
|
||||
|
||||
def remote_get_service(self, name):
|
||||
# TODO: 'vdrive' should not be public in the medium term
|
||||
return self.getServiceNamed(name)
|
||||
|
@ -25,6 +25,19 @@ class RIIntroducer(RemoteInterface):
|
||||
return None
|
||||
|
||||
class RIClient(RemoteInterface):
|
||||
def get_versions():
|
||||
"""Return a tuple of (my_version, oldest_supported) strings.
|
||||
|
||||
Each string can be parsed by an allmydata.util.version.Version
|
||||
instance, and then compared. The first goal is to make sure that
|
||||
nodes are not confused by speaking to an incompatible peer. The
|
||||
second goal is to enable the development of backwards-compatibility
|
||||
code.
|
||||
|
||||
This method is likely to change in incompatible ways until we get the
|
||||
whole compatibility scheme nailed down.
|
||||
"""
|
||||
return TupleOf(str, str)
|
||||
def get_service(name=str):
|
||||
return Referenceable
|
||||
def get_nodeid():
|
||||
|
@ -2,7 +2,9 @@
|
||||
import os
|
||||
from twisted.trial import unittest
|
||||
|
||||
import allmydata
|
||||
from allmydata import client, introducer
|
||||
from allmydata.util import version
|
||||
|
||||
class MyIntroducerClient(introducer.IntroducerClient):
|
||||
def __init__(self):
|
||||
@ -39,3 +41,12 @@ class Basic(unittest.TestCase):
|
||||
c2.introducer_client.connections[k] = None
|
||||
self.failUnlessEqual(permute(c2, "one"), ['3','1','0','4','2'])
|
||||
|
||||
def test_versions(self):
|
||||
basedir = "test_client.Basic.test_versions"
|
||||
os.mkdir(basedir)
|
||||
open(os.path.join(basedir, "introducer.furl"), "w").write("")
|
||||
open(os.path.join(basedir, "vdrive.furl"), "w").write("")
|
||||
c = client.Client(basedir)
|
||||
mine, oldest = c.remote_get_versions()
|
||||
self.failUnlessEqual(version.Version(mine), allmydata.__version__)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user