BLOCK_PERIOD=600, # s
SYMBOL='BTC',
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Bitcoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Bitcoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.bitcoin'), 'bitcoin.conf'),
+ BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/block/',
),
bitcoin_testnet=math.Object(
P2P_PREFIX='fabfb5da'.decode('hex'),
BLOCK_PERIOD=600, # s
SYMBOL='tBTC',
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Bitcoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Bitcoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.bitcoin'), 'bitcoin.conf'),
+ BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/block/',
),
nameecoin=math.Object(
BLOCK_PERIOD=600, # s
SYMBOL='NMC',
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Namecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Namecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.namecoin'), 'bitcoin.conf'),
+ BLOCK_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/b/',
),
namecoin_testnet=math.Object(
P2P_PREFIX='fabfb5fe'.decode('hex'),
BLOCK_PERIOD=600, # s
SYMBOL='tNMC',
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Namecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Namecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.namecoin'), 'bitcoin.conf'),
+ BLOCK_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/b/',
),
litecoin=math.Object(
BLOCK_PERIOD=150, # s
SYMBOL='LTC',
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Litecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Litecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.litecoin'), 'litecoin.conf'),
+ BLOCK_EXPLORER_URL_PREFIX='http://litecoin.kicks-ass.org/block/',
),
litecoin_testnet=math.Object(
P2P_PREFIX='fcc1b7dc'.decode('hex'),
BLOCK_PERIOD=150, # s
SYMBOL='tLTC',
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Litecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Litecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.litecoin'), 'litecoin.conf'),
+ BLOCK_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/block/',
),
)
+for net_name, net in nets.iteritems():
+ net.NAME = net_name
else:
print >>sys.stderr, 'No bitcoind connection when block submittal attempted! Erp!'
print
- print 'GOT BLOCK FROM PEER! Passing to bitcoind! %s bitcoin: %x' % (p2pool_data.format_hash(share.hash), share.header_hash)
+ print 'GOT BLOCK FROM PEER! Passing to bitcoind! %s bitcoin: %s%064x' % (p2pool_data.format_hash(share.hash), net.PARENT.BLOCK_EXPLORER_URL_PREFIX, share.header_hash)
print
- recent_blocks.append({ 'ts': share.timestamp, 'hash': '%x' % (share.header_hash) })
+ recent_blocks.append(dict(ts=share.timestamp, hash='%064x' % (share.header_hash,)))
print 'Joining p2pool network using port %i...' % (args.p2pool_port,)
@deferral.retry('Error submitting primary block: (will retry)', 10, 10)
def submit_block():
if factory.conn.value is None:
- print >>sys.stderr, 'No bitcoind connection when block submittal attempted! Hash: %x' % (header_hash,)
+ print >>sys.stderr, 'No bitcoind connection when block submittal attempted! %s%32x' % (net.PARENT.BLOCK_EXPLORER_URL_PREFIX, header_hash)
raise deferral.RetrySilentlyException()
factory.conn.value.send_block(block=dict(header=header, txs=transactions))
submit_block()
if pow_hash <= header['bits'].target:
print
- print 'GOT BLOCK FROM MINER! Passing to bitcoind! bitcoin: %x' % (header_hash,)
+ print 'GOT BLOCK FROM MINER! Passing to bitcoind! %s%064x' % (net.PARENT.BLOCK_EXPLORER_URL_PREFIX, header_hash)
print
- recent_blocks.append(dict(ts=time.time(), hash='%x' % (header_hash,)))
+ recent_blocks.append(dict(ts=time.time(), hash='%064x' % (header_hash,)))
except:
log.err(None, 'Error while processing potential block:')
if args.irc_announce:
from twisted.words.protocols import irc
class IRCClient(irc.IRCClient):
- nickname = 'p2pool'
+ nickname = 'p2pool_%s%i' % (net.NAME, random.randrange(100))
def lineReceived(self, line):
print repr(line)
irc.IRCClient.lineReceived(self, line)
def _new_share(self, share):
if share.pow_hash <= share.header['bits'].target and share.header_hash not in self.announced_hashes and abs(share.timestamp - time.time()) < 10*60:
self.announced_hashes.add(share.header_hash)
- self.say('#p2pool', '\x02BLOCK FOUND by %s! http://blockexplorer.com/block/%064x' % (bitcoin_data.script2_to_address(share.share_data['new_script'], net.PARENT), share.header_hash))
+ self.say('#p2pool', '\x02BLOCK FOUND by %s! %s%064x' % (bitcoin_data.script2_to_address(share.share_data['new_script'], net.PARENT), net.PARENT.BLOCK_EXPLORER_URL_PREFIX, share.header_hash))
def connectionLost(self, reason):
tracker.verified.added.unwatch(self.watch_id)
print 'IRC connection lost:', reason.getErrorMessage()