Skip to content

Commit

Permalink
Merge pull request #86 from wtogami/master
Browse files Browse the repository at this point in the history
Fix p2pool's stratum scrypt support
  • Loading branch information
forrestv committed Mar 22, 2013
2 parents 7b73477 + c8cd400 commit 896c9ed
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions p2pool/bitcoin/networks.py
Expand Up @@ -24,6 +24,7 @@
BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/address/',
SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
),
bitcoin_testnet=math.Object(
P2P_PREFIX='0b110907'.decode('hex'),
Expand All @@ -42,6 +43,7 @@
BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/address/',
SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
),

namecoin=math.Object(
Expand All @@ -61,6 +63,7 @@
BLOCK_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/b/',
ADDRESS_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/a/',
SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
),
namecoin_testnet=math.Object(
P2P_PREFIX='fabfb5fe'.decode('hex'),
Expand All @@ -79,6 +82,7 @@
BLOCK_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/b/',
ADDRESS_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/a/',
SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
),

litecoin=math.Object(
Expand All @@ -98,6 +102,7 @@
BLOCK_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/address/',
SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1),
DUMB_SCRYPT_DIFF=2**16,
),
litecoin_testnet=math.Object(
P2P_PREFIX='fcc1b7dc'.decode('hex'),
Expand All @@ -116,6 +121,7 @@
BLOCK_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/address/',
SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256 - 1),
DUMB_SCRYPT_DIFF=2**16,
),

terracoin=math.Object(
Expand All @@ -135,6 +141,7 @@
BLOCK_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/address/',
SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
),
terracoin_testnet=math.Object(
P2P_PREFIX='41babe56'.decode('hex'),
Expand All @@ -153,6 +160,7 @@
BLOCK_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/address/',
SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
),

)
Expand Down
2 changes: 1 addition & 1 deletion p2pool/bitcoin/stratum.py
Expand Up @@ -34,7 +34,7 @@ def rpc_authorize(self, username, password):
def _send_work(self):
x, got_response = self.wb.get_work(*self.wb.preprocess_request('' if self.username is None else self.username))
jobid = str(random.randrange(2**128))
self.other.svc_mining.rpc_set_difficulty(bitcoin_data.target_to_difficulty(x['share_target'])).addErrback(lambda err: None)
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)
self.other.svc_mining.rpc_notify(
jobid, # jobid
getwork._swap4(pack.IntType(256).pack(x['previous_block'])).encode('hex'), # prevhash
Expand Down
1 change: 1 addition & 0 deletions p2pool/bitcoin/worker_interface.py
Expand Up @@ -102,6 +102,7 @@ def _getwork(self, request, data, long_poll):
class CachingWorkerBridge(object):
def __init__(self, inner):
self._inner = inner
self.net = self._inner.net

self.COINBASE_NONCE_LENGTH = (inner.COINBASE_NONCE_LENGTH+1)//2
self.new_work_event = inner.new_work_event
Expand Down
1 change: 1 addition & 0 deletions p2pool/work.py
Expand Up @@ -25,6 +25,7 @@ def __init__(self, node, my_pubkey_hash, donation_percentage, merged_urls, worke
self.donation_percentage = donation_percentage
self.worker_fee = worker_fee

self.net = self.node.net.PARENT
self.running = True
self.pseudoshare_received = variable.Event()
self.share_received = variable.Event()
Expand Down

0 comments on commit 896c9ed

Please sign in to comment.