From 8d2def5b04c6751b393c1117ea3372583fcc5b87 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 5 Apr 2007 22:36:18 -0700 Subject: [PATCH] encode: clean up some weirdness that was there to make unit tests easier to write --- src/allmydata/encode.py | 15 +++++++-------- src/allmydata/test/test_encode.py | 8 -------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/allmydata/encode.py b/src/allmydata/encode.py index a0e92922..7d958b37 100644 --- a/src/allmydata/encode.py +++ b/src/allmydata/encode.py @@ -229,11 +229,8 @@ class Encoder(object): return dl def send_subshare(self, shareid, segment_num, subshare): - return self.send(shareid, "put_block", segment_num, subshare) - - def send(self, shareid, methname, *args, **kwargs): - ll = self.landlords[shareid] - return ll.callRemote(methname, *args, **kwargs) + sh = self.landlords[shareid] + return sh.callRemote("put_block", segment_num, subshare) def send_all_subshare_hash_trees(self): dl = [] @@ -250,7 +247,8 @@ class Encoder(object): # all_hashes[1] is the left child, == hash(ah[3]+ah[4]) # all_hashes[n] == hash(all_hashes[2*n+1] + all_hashes[2*n+2]) self.share_root_hashes[shareid] = t[0] - return self.send(shareid, "put_block_hashes", all_hashes) + sh = self.landlords[shareid] + return sh.callRemote("put_block_hashes", all_hashes) def send_all_share_hash_trees(self): dl = [] @@ -272,12 +270,13 @@ class Encoder(object): return defer.DeferredList(dl) def send_one_share_hash_tree(self, shareid, needed_hashes): - return self.send(shareid, "put_share_hashes", needed_hashes) + sh = self.landlords[shareid] + return sh.callRemote("put_share_hashes", needed_hashes) def close_all_shareholders(self): dl = [] for shareid in range(self.num_shares): - dl.append(self.send(shareid, "close")) + dl.append(self.landlords[shareid].callRemote("close")) return defer.DeferredList(dl) def done(self): diff --git a/src/allmydata/test/test_encode.py b/src/allmydata/test/test_encode.py index 71a91d7e..6372af89 100644 --- a/src/allmydata/test/test_encode.py +++ b/src/allmydata/test/test_encode.py @@ -7,14 +7,6 @@ from allmydata import encode, download from allmydata.uri import pack_uri from cStringIO import StringIO -class MyEncoder(encode.Encoder): - def send(self, share_num, methname, *args, **kwargs): - if False and share_num < 10: - print "send[%d].%s()" % (share_num, methname) - if methname == "put_share_hashes": - print " ", [i for i,h in args[0]] - return defer.succeed(None) - class FakePeer: def __init__(self, mode="good"): self.ss = FakeStorageServer(mode) -- 2.45.2