From: coblee Date: Sun, 6 Nov 2011 04:14:48 +0000 (-0700) Subject: Add Litecoin network. X-Git-Tag: 0.8.2~183 X-Git-Url: https://git.novaco.in/?p=p2pool.git;a=commitdiff_plain;h=9b7cf5fb5456dc520e524d67f50a5cc62750455f Add Litecoin network. --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a6bd1f --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.pyc +*.dat +*.iml +*.log +*_shares.* +.idea diff --git a/p2pool/data.py b/p2pool/data.py index 560efe5..161edc3 100644 --- a/p2pool/data.py +++ b/p2pool/data.py @@ -8,7 +8,7 @@ import os from twisted.python import log import p2pool -from p2pool import skiplists, namecoin, ixcoin, i0coin, solidcoin +from p2pool import skiplists, namecoin, ixcoin, i0coin, solidcoin, litecoin from p2pool.bitcoin import data as bitcoin_data, script from p2pool.util import memoize, expiring_dict, math @@ -662,4 +662,32 @@ class SolidcoinMainnet(solidcoin.SolidcoinMainnet): PERSIST = True WORKER_PORT = 9328 -nets = dict((net.NAME, net) for net in set([Mainnet, Testnet, NamecoinMainnet, NamecoinTestnet, IxcoinMainnet, IxcoinTestnet, I0coinMainnet, I0coinTestnet, SolidcoinMainnet])) +class LitecoinMainnet(litecoin.LitecoinMainnet): + SHARE_PERIOD = 10 # seconds + CHAIN_LENGTH = 24*60*60//5 # shares + TARGET_LOOKBEHIND = 200 # shares + SPREAD = 12 # blocks + SCRIPT = '410403ad3dee8ab3d8a9ce5dd2abfbe7364ccd9413df1d279bf1a207849310465b0956e5904b1155ecd17574778f9949589ebfd4fb33ce837c241474a225cf08d85dac'.decode('hex') + IDENTIFIER = 'e037d5b8c6923410'.decode('hex') + PREFIX = '7208c1a53ef629b0'.decode('hex') + NAME = 'litecoin' + P2P_PORT = 9338 + MAX_TARGET = 2**256//2**32 - 1 + PERSIST = True + WORKER_PORT = 9327 + +class LitecoinTestnet(litecoin.LitecoinTestnet): + SHARE_PERIOD = 1 # seconds + CHAIN_LENGTH = 24*60*60//5 # shares + TARGET_LOOKBEHIND = 200 # shares + SPREAD = 12 # blocks + SCRIPT = '410403ad3dee8ab3d8a9ce5dd2abfbe7364ccd9413df1d279bf1a207849310465b0956e5904b1155ecd17574778f9949589ebfd4fb33ce837c241474a225cf08d85dac'.decode('hex') + IDENTIFIER = 'cca5e24ec6408b1e'.decode('hex') + PREFIX = 'ad9614f6466a39cf'.decode('hex') + NAME = 'litecoin_testnet' + P2P_PORT = 19338 + MAX_TARGET = 2**256//2**20 - 1 + PERSIST = False + WORKER_PORT = 19327 + +nets = dict((net.NAME, net) for net in set([Mainnet, Testnet, NamecoinMainnet, NamecoinTestnet, IxcoinMainnet, IxcoinTestnet, I0coinMainnet, I0coinTestnet, SolidcoinMainnet, LitecoinMainnet, LitecoinTestnet])) diff --git a/p2pool/litecoin.py b/p2pool/litecoin.py new file mode 100644 index 0000000..81a0916 --- /dev/null +++ b/p2pool/litecoin.py @@ -0,0 +1,25 @@ +from twisted.internet import defer + +class LitecoinMainnet(object): + BITCOIN_P2P_PREFIX = 'fbc0b6db'.decode('hex') + BITCOIN_P2P_PORT = 9333 + BITCOIN_ADDRESS_VERSION = 48 + BITCOIN_RPC_PORT = 9332 + BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue( + 'litecoinaddress' in (yield bitcoind.rpc_help()) and + not (yield bitcoind.rpc_getinfo())['testnet'] + ))) + BITCOIN_SUBSIDY_FUNC = staticmethod(lambda height: 50*100000000 >> (height + 1)//840000) + BITCOIN_SYMBOL = 'LTC' + +class LitecoinTestnet(object): + BITCOIN_P2P_PREFIX = 'fcc1b7dc'.decode('hex') + BITCOIN_P2P_PORT = 19333 + BITCOIN_ADDRESS_VERSION = 111 + BITCOIN_RPC_PORT = 19332 + BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue( + 'litecoinaddress' in (yield bitcoind.rpc_help()) and + (yield bitcoind.rpc_getinfo())['testnet'] + ))) + BITCOIN_SUBSIDY_FUNC = staticmethod(lambda height: 50*100000000 >> (height + 1)//840000) + BITCOIN_SYMBOL = 'tLTC' diff --git a/p2pool/main.py b/p2pool/main.py index c588fde..bf2ce33 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -731,7 +731,7 @@ def run(): worker_group = parser.add_argument_group('worker interface') worker_group.add_argument('-w', '--worker-port', metavar='PORT', - help='listen on PORT for RPC connections from miners asking for work and providing responses (default: bitcoin: 9332 namecoin: 9331 ixcoin: 9330 i0coin: 9329, +10000 for testnets)', + help='listen on PORT for RPC connections from miners asking for work and providing responses (default: bitcoin: 9332 namecoin: 9331 ixcoin: 9330 i0coin: 9329 solidcoin: 9328 litecoin: 9327, +10000 for testnets)', type=int, action='store', default=None, dest='worker_port') worker_group.add_argument('-f', '--fee', metavar='FEE_PERCENTAGE', help='''charge workers mining to their own bitcoin address (by setting their miner's username to a bitcoin address) this percentage fee to mine on your p2pool instance. Amount displayed at http://127.0.0.1:9332/fee . default: 0''', @@ -742,10 +742,10 @@ def run(): help='connect to a bitcoind at this address (default: 127.0.0.1)', type=str, action='store', default='127.0.0.1', dest='bitcoind_address') bitcoind_group.add_argument('--bitcoind-rpc-port', metavar='BITCOIND_RPC_PORT', - help='connect to a bitcoind at this port over the RPC interface - used to get the current highest block via getwork (default: 8332, 8338 for ixcoin)', + help='connect to a bitcoind at this port over the RPC interface - used to get the current highest block via getwork (default: 8332 ixcoin: 8338 i0coin: 7332 litecoin: 9332)', type=int, action='store', default=None, dest='bitcoind_rpc_port') bitcoind_group.add_argument('--bitcoind-p2p-port', metavar='BITCOIND_P2P_PORT', - help='connect to a bitcoind at this port over the p2p interface - used to submit blocks and get the pubkey to generate to via an IP transaction (default: 8333 normally. 18333 for testnet)', + help='connect to a bitcoind at this port over the p2p interface - used to submit blocks and get the pubkey to generate to via an IP transaction (default: 8333 namecoin: 8334 ixcoin: 8337 i0coin: 7333 solidcoin: 7555 litecoin: 9333, +10000 for testnets)', type=int, action='store', default=None, dest='bitcoind_p2p_port') bitcoind_group.add_argument(metavar='BITCOIND_RPCUSER',