From: Forrest Voight Date: Sat, 3 Mar 2012 23:28:31 +0000 (-0500) Subject: cleaned up preprocess_request in preparation for X-Git-Tag: 0.10.0~76 X-Git-Url: https://git.novaco.in/?p=p2pool.git;a=commitdiff_plain;h=63ecfb00ece18cdd5f32d495a35a8a8e3013758a cleaned up preprocess_request in preparation for --- diff --git a/p2pool/main.py b/p2pool/main.py index 3217991..15d0ff2 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -448,23 +448,26 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint): def preprocess_request(self, request): user = request.getUser() if request.getUser() is not None else '' - pubkey_hash = my_pubkey_hash - max_target = 2**256 - 1 + + desired_share_target = 2**256 - 1 if '/' in user: user, min_diff_str = user.rsplit('/', 1) try: - max_target = bitcoin_data.difficulty_to_target(float(min_diff_str)) + desired_share_target = bitcoin_data.difficulty_to_target(float(min_diff_str)) except: pass - try: - pubkey_hash = bitcoin_data.address_to_pubkey_hash(user, net.PARENT) - except: # XXX blah - pass + if random.uniform(0, 100) < args.worker_fee: pubkey_hash = my_pubkey_hash - return pubkey_hash, max_target + else: + try: + pubkey_hash = bitcoin_data.address_to_pubkey_hash(user, net.PARENT) + except: # XXX blah + pubkey_hash = my_pubkey_hash + + return pubkey_hash, desired_share_target - def get_work(self, pubkey_hash, max_target): + def get_work(self, pubkey_hash, desired_share_target): if len(p2p_node.peers) == 0 and net.PERSIST: raise jsonrpc.Error(-12345, u'p2pool is not connected to any peers') if current_work.value['best_share_hash'] is None and net.PERSIST: @@ -505,7 +508,7 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint): ), block_target=current_work.value['bits'].target, desired_timestamp=int(time.time() - current_work2.value['clock_offset']), - desired_target=max_target, + desired_target=desired_share_target, net=net, ) else: