changed arguments to add_dicts
authorForrest Voight <forrest@forre.st>
Tue, 13 Dec 2011 11:34:58 +0000 (06:34 -0500)
committerForrest Voight <forrest@forre.st>
Tue, 13 Dec 2011 11:34:58 +0000 (06:34 -0500)
p2pool/data.py
p2pool/skiplists.py
p2pool/util/math.py

index a42b97e..a6695d5 100644 (file)
@@ -214,7 +214,7 @@ def generate_transaction(tracker, share_data, block_target, desired_timestamp, n
     this_att = min(bitcoin_data.target_to_average_attempts(target), max_att)
     other_weights, other_total_weight, other_donation_weight = tracker.get_cumulative_weights(previous_share_hash, min(height, chain_length), 65535*max(0, max_att - this_att))
     assert other_total_weight == sum(other_weights.itervalues()) + other_donation_weight, (other_total_weight, sum(other_weights.itervalues()) + other_donation_weight)
-    weights, total_weight, donation_weight = math.add_dicts([{new_script: this_att*(65535-donation)}, other_weights]), this_att*65535 + other_total_weight, this_att*donation + other_donation_weight
+    weights, total_weight, donation_weight = math.add_dicts({new_script: this_att*(65535-donation)}, other_weights), this_att*65535 + other_total_weight, this_att*donation + other_donation_weight
     assert total_weight == sum(weights.itervalues()) + donation_weight, (total_weight, sum(weights.itervalues()) + donation_weight)
     
     SCRIPT = '4104ffd03de44a6e11b9917f3a29f9443283d9871c9d743ef30d5eddcd37094b64d1b3d8090496b53256786bf5c82932ec23c3b74d9f05a6f95a8b5529352656664bac'.decode('hex')
index 6baac98..e6dbeb6 100644 (file)
@@ -19,7 +19,7 @@ class WeightsSkipList(skiplist.SkipList):
         return 1, {share.new_script: att*(65535-share.donation)}, att*65535, att*share.donation
     
     def combine_deltas(self, (share_count1, weights1, total_weight1, total_donation_weight1), (share_count2, weights2, total_weight2, total_donation_weight2)):
-        return share_count1 + share_count2, math.add_dicts([weights1, weights2]), total_weight1 + total_weight2, total_donation_weight1 + total_donation_weight2
+        return share_count1 + share_count2, math.add_dicts(weights1, weights2), total_weight1 + total_weight2, total_donation_weight1 + total_donation_weight2
     
     def initial_solution(self, start, (max_shares, desired_weight)):
         assert desired_weight % 65535 == 0, divmod(desired_weight, 65535)
@@ -32,7 +32,7 @@ class WeightsSkipList(skiplist.SkipList):
             assert (desired_weight - total_weight1) % 65535 == 0
             new_weights[script] = new_weights.get(script, 0) + (desired_weight - total_weight1)//65535*weights2[script]//(total_weight2//65535)
             return share_count1 + share_count2, new_weights, desired_weight, total_donation_weight1 + (desired_weight - total_weight1)//65535*total_donation_weight2//(total_weight2//65535)
-        return share_count1 + share_count2, math.add_dicts([weights1, weights2]), total_weight1 + total_weight2, total_donation_weight1 + total_donation_weight2
+        return share_count1 + share_count2, math.add_dicts(weights1, weights2), total_weight1 + total_weight2, total_donation_weight1 + total_donation_weight2
     
     def judge(self, (share_count, weights, total_weight, total_donation_weight), (max_shares, desired_weight)):
         if share_count > max_shares or total_weight > desired_weight:
index 68f3f26..0352bb6 100644 (file)
@@ -49,7 +49,7 @@ def geometric(p):
         return 1
     return int(math.log1p(-random.random()) / math.log1p(-p)) + 1
 
-def add_dicts(dicts):
+def add_dicts(*dicts):
     res = {}
     for d in dicts:
         for k, v in d.iteritems():