Skip to content
This repository
Browse code

Make p2pool's stratum implementation match the dumb de facto diff sta…

…ndard of scrypt stratum pools.
  • Loading branch information...
commit c8cd400c430279493029b67cc5055eb645a967d9 1 parent 7b73477
Warren Togami authored March 21, 2013
8  p2pool/bitcoin/networks.py
@@ -24,6 +24,7 @@
24 24
         BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/block/',
25 25
         ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/address/',
26 26
         SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
  27
+        DUMB_SCRYPT_DIFF=1,
27 28
     ),
28 29
     bitcoin_testnet=math.Object(
29 30
         P2P_PREFIX='0b110907'.decode('hex'),
@@ -42,6 +43,7 @@
42 43
         BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/block/',
43 44
         ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/address/',
44 45
         SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
  46
+        DUMB_SCRYPT_DIFF=1,
45 47
     ),
46 48
     
47 49
     namecoin=math.Object(
@@ -61,6 +63,7 @@
61 63
         BLOCK_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/b/',
62 64
         ADDRESS_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/a/',
63 65
         SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
  66
+        DUMB_SCRYPT_DIFF=1,
64 67
     ),
65 68
     namecoin_testnet=math.Object(
66 69
         P2P_PREFIX='fabfb5fe'.decode('hex'),
@@ -79,6 +82,7 @@
79 82
         BLOCK_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/b/',
80 83
         ADDRESS_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/a/',
81 84
         SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
  85
+        DUMB_SCRYPT_DIFF=1,
82 86
     ),
83 87
     
84 88
     litecoin=math.Object(
@@ -98,6 +102,7 @@
98 102
         BLOCK_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/block/',
99 103
         ADDRESS_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/address/',
100 104
         SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1),
  105
+        DUMB_SCRYPT_DIFF=2**16,
101 106
     ),
102 107
     litecoin_testnet=math.Object(
103 108
         P2P_PREFIX='fcc1b7dc'.decode('hex'),
@@ -116,6 +121,7 @@
116 121
         BLOCK_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/block/',
117 122
         ADDRESS_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/address/',
118 123
         SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256 - 1),
  124
+        DUMB_SCRYPT_DIFF=2**16,
119 125
     ),
120 126
 
121 127
     terracoin=math.Object(
@@ -135,6 +141,7 @@
135 141
         BLOCK_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/block/',
136 142
         ADDRESS_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/address/',
137 143
         SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
  144
+        DUMB_SCRYPT_DIFF=1,
138 145
     ),
139 146
     terracoin_testnet=math.Object(
140 147
         P2P_PREFIX='41babe56'.decode('hex'),
@@ -153,6 +160,7 @@
153 160
         BLOCK_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/block/',
154 161
         ADDRESS_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/address/',
155 162
         SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
  163
+        DUMB_SCRYPT_DIFF=1,
156 164
     ),
157 165
 
158 166
 )
2  p2pool/bitcoin/stratum.py
@@ -34,7 +34,7 @@ def rpc_authorize(self, username, password):
34 34
     def _send_work(self):
35 35
         x, got_response = self.wb.get_work(*self.wb.preprocess_request('' if self.username is None else self.username))
36 36
         jobid = str(random.randrange(2**128))
37  
-        self.other.svc_mining.rpc_set_difficulty(bitcoin_data.target_to_difficulty(x['share_target'])).addErrback(lambda err: None)
  37
+        self.other.svc_mining.rpc_set_difficulty(bitcoin_data.target_to_difficulty(x['share_target'])*self.wb.net.DUMB_SCRYPT_DIFF).addErrback(lambda err: None)
38 38
         self.other.svc_mining.rpc_notify(
39 39
             jobid, # jobid
40 40
             getwork._swap4(pack.IntType(256).pack(x['previous_block'])).encode('hex'), # prevhash
1  p2pool/bitcoin/worker_interface.py
@@ -102,6 +102,7 @@ def _getwork(self, request, data, long_poll):
102 102
 class CachingWorkerBridge(object):
103 103
     def __init__(self, inner):
104 104
         self._inner = inner
  105
+        self.net = self._inner.net
105 106
         
106 107
         self.COINBASE_NONCE_LENGTH = (inner.COINBASE_NONCE_LENGTH+1)//2
107 108
         self.new_work_event = inner.new_work_event
1  p2pool/work.py
@@ -25,6 +25,7 @@ def __init__(self, node, my_pubkey_hash, donation_percentage, merged_urls, worke
25 25
         self.donation_percentage = donation_percentage
26 26
         self.worker_fee = worker_fee
27 27
         
  28
+        self.net = self.node.net.PARENT
28 29
         self.running = True
29 30
         self.pseudoshare_received = variable.Event()
30 31
         self.share_received = variable.Event()

0 notes on commit c8cd400

Please sign in to comment.
Something went wrong with that request. Please try again.