some more work
authorForrest Voight <forrest.voight@gmail.com>
Fri, 18 Nov 2011 06:46:28 +0000 (01:46 -0500)
committerForrest Voight <forrest.voight@gmail.com>
Fri, 18 Nov 2011 06:46:28 +0000 (01:46 -0500)
p2pool/data.py
p2pool/skiplists.py

index 7aef52a..bef05a3 100644 (file)
@@ -307,6 +307,7 @@ def new_generate_transaction(tracker, new_share_data, block_target, net):
     previous_share_hash = new_share_data['previous_share_hash']
     new_script = new_share_data['new_script']
     subsidy = new_share_data['subsidy']
+    donation = new_share_data['subsidy']
     
     height, last = tracker.get_height_and_last(previous_share_hash)
     assert height >= net.CHAIN_LENGTH or last is None
@@ -325,7 +326,7 @@ def new_generate_transaction(tracker, new_share_data, block_target, net):
     
     this_weight = min(bitcoin_data.target_to_average_attempts(target), max_weight)
     other_weights, other_weights_total = tracker.get_cumulative_weights(previous_share_hash, min(height, net.CHAIN_LENGTH), max(0, max_weight - this_weight))
-    dest_weights, total_weight = math.add_dicts([{new_script: this_weight}, other_weights]), this_weight + other_weights_total
+    dest_weights, total_weight = math.add_dicts([{new_script: (this_weight, this_weight*donation)}, other_weights]), this_weight + other_weights_total
     assert total_weight == sum(dest_weights.itervalues())
     
     amounts = dict((script, subsidy*(396*weight)//(400*total_weight)) for (script, weight) in dest_weights.iteritems())
index 9e62188..0a28dde 100644 (file)
@@ -16,20 +16,20 @@ class WeightsSkipList(skiplist.SkipList):
             return (2**256, {}, 0) # XXX
         share = self.tracker.shares[element]
         att = bitcoin_data.target_to_average_attempts(share.target)
-        return 1, {share.new_script: att}, att
+        return 1, {share.new_script: att*(65535-share.donation)}, att, att*share.donation
     
-    def combine_deltas(self, (share_count1, weights1, total_weight1), (share_count2, weights2, total_weight2)):
-        return share_count1 + share_count2, math.add_dicts([weights1, weights2]), total_weight1 + total_weight2
+    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
     
     def initial_solution(self, start, (max_shares, desired_weight)):
-        return 0, {}, 0
+        return 0, {}, 0, 0
     
-    def apply_delta(self, (share_count1, weights1, total_weight1), (share_count2, weights2, total_weight2), (max_shares, desired_weight)):
+    def apply_delta(self, (share_count1, weights1, total_weight1, total_donation_weight1), (share_count2, weights2, total_weight2, total_donation_weight2), (max_shares, desired_weight)):
         if total_weight1 + total_weight2 > desired_weight and len(weights2) == 1:
             script, = weights2.iterkeys()
             new_weights = dict(weights1)
             new_weights[script] = new_weights.get(script, 0) + desired_weight - total_weight1
-            return share_count1 + share_count2, new_weights, desired_weight
+            return share_count1 + share_count2, new_weights, desired_weight, 
         return share_count1 + share_count2, math.add_dicts([weights1, weights2]), total_weight1 + total_weight2
     
     def judge(self, (share_count, weights, total_weight), (max_shares, desired_weight)):