From: Forrest Voight Date: Sun, 16 Oct 2011 10:35:16 +0000 (-0400) Subject: very preliminary merged mining support. has never produced a merged block but definit... X-Git-Tag: 0.8.2~184^2~1 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=132a40e94ee79cd58c90d66c012d6b3c673337f6;p=p2pool.git very preliminary merged mining support. has never produced a merged block but definitely should work (probably). mine to an address, not a public key. --- diff --git a/p2pool/bitcoin/data.py b/p2pool/bitcoin/data.py index d0cbc0b..473ea3a 100644 --- a/p2pool/bitcoin/data.py +++ b/p2pool/bitcoin/data.py @@ -432,6 +432,13 @@ tx_type = ComposedType([ ('lock_time', StructType(' 100: - raise ValueError('''coinbase too large!''') + raise ValueError('''coinbase too large! %i bytes''' % (len(gentx['tx_ins'][0]['script']),)) if check_merkle_branch(gentx, self.merkle_branch) != self.header['merkle_root']: raise ValueError('''gentx doesn't match header via merkle_branch''') diff --git a/p2pool/main.py b/p2pool/main.py index 259b935..c588fde 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -171,6 +171,7 @@ def main(args): previous_block=work['previous_block_hash'], target=work['target'], best_share_hash=current_work.value['best_share_hash'] if current_work.value is not None else None, + aux_work=current_work.value['aux_work'] if current_work.value is not None else None, )) current_work2.set(dict( transactions=work['transactions'], @@ -222,6 +223,24 @@ def main(args): print ' ...success!' print + @defer.inlineCallbacks + def set_merged_work(): + if not args.merged_url: + return + while True: + merged = jsonrpc.Proxy(args.merged_url, (args.merged_userpass,)) + auxblock = yield deferral.retry('Error while calling merged getauxblock:', 1)(merged.rpc_getauxblock)() + x = dict(current_work.value) + x['aux_work'] = dict( + hash=int(auxblock['hash'], 16), + target=bitcoin.data.HashType().unpack(auxblock['target'].decode('hex')), + chain_id=auxblock['chainid'], + ) + #print x['aux_work'] + current_work.set(x) + yield deferral.sleep(1) + set_merged_work() + start_time = time.time() - current_work2.value['clock_offset'] # setup p2p logic and join p2pool network @@ -376,7 +395,7 @@ def main(args): # setup worker logic merkle_root_to_transactions = expiring_dict.ExpiringDict(300) - run_identifier = struct.pack(' current_work2.value['last_update'] + 60: raise jsonrpc.Error(-12345, u'lost contact with bitcoind') + if state['aux_work'] is not None: + aux_str = '\xfa\xbemm' + bitcoin.data.HashType().pack(state['aux_work']['hash'])[::-1] + struct.pack(' target: print 'Worker submitted share with hash > target:\nhash : %x\ntarget: %x' % (hash_, target) @@ -663,6 +708,12 @@ def run(): parser.add_argument('--logfile', help='''log to specific file (defaults to .log in run_p2pool.py's directory)''', type=str, action='store', default=None, dest='logfile') + parser.add_argument('--merged-url', + help='call getauxblock on this url to get work for merged mining', + type=str, action='store', default=None, dest='merged_url') + parser.add_argument('--merged-userpass', + help='merge daemon user and password, separated by a colon. Example: ncuser:ncpass', + type=str, action='store', default=None, dest='merged_userpass') p2pool_group = parser.add_argument_group('p2pool interface') p2pool_group.add_argument('--p2pool-port', metavar='PORT', @@ -794,5 +845,8 @@ def run(): else: args.pubkey_hash = None + if (args.merged_url is None) ^ (args.merged_userpass is None): + parser.error('must specify --merged-url and --merged-userpass') + reactor.callWhenRunning(main, args) reactor.run()