ixcoin support
authorForrest Voight <forrest@forre.st>
Mon, 15 Aug 2011 01:13:33 +0000 (21:13 -0400)
committerForrest Voight <forrest@forre.st>
Mon, 15 Aug 2011 01:13:33 +0000 (21:13 -0400)
p2pool/bitcoin/data.py
p2pool/data.py
p2pool/ixcoin.py [new file with mode: 0644]
p2pool/main.py
p2pool/namecoin.py

index 1edae88..97ed7aa 100644 (file)
@@ -800,10 +800,22 @@ class Mainnet(object):
     BITCOIN_P2P_PREFIX = 'f9beb4d9'.decode('hex')
     BITCOIN_P2P_PORT = 8333
     BITCOIN_ADDRESS_VERSION = 0
-    BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue('name_firstupdate' not in (yield bitcoind.rpc_help()) and not (yield bitcoind.rpc_getinfo())['testnet'])))
+    BITCOIN_RPC_PORT = 8332
+    BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
+        'name_firstupdate' not in (yield bitcoind.rpc_help()) and
+        'ixcoinaddress' not in (yield bitcoind.rpc_help()) and
+        not (yield bitcoind.rpc_getinfo())['testnet']
+    )))
+    BITCOIN_SUBSIDY_FUNC = staticmethod(lambda height: 50*100000000 >> (height + 1)//210000)
 
 class Testnet(object):
     BITCOIN_P2P_PREFIX = 'fabfb5da'.decode('hex')
     BITCOIN_P2P_PORT = 18333
     BITCOIN_ADDRESS_VERSION = 111
-    BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue('name_firstupdate' not in (yield bitcoind.rpc_help()) and (yield bitcoind.rpc_getinfo())['testnet'])))
+    BITCOIN_RPC_PORT = 8332
+    BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
+        'name_firstupdate' not in (yield bitcoind.rpc_help()) and
+        'ixcoinaddress' not in (yield bitcoind.rpc_help()) and
+        (yield bitcoind.rpc_getinfo())['testnet']
+    )))
+    BITCOIN_SUBSIDY_FUNC = staticmethod(lambda height: 50*100000000 >> (height + 1)//210000)
index 6a76dee..050dcd9 100644 (file)
@@ -7,7 +7,7 @@ import time
 from twisted.python import log
 
 import p2pool
-from p2pool import skiplists, namecoin
+from p2pool import skiplists, namecoin, ixcoin
 from p2pool.bitcoin import data as bitcoin_data, script
 from p2pool.util import memoize, expiring_dict, math
 
@@ -544,3 +544,32 @@ class NamecoinTestnet(namecoin.NamecoinTestnet):
     SHARESTORE_FILENAME = 'namecoin_testnet_shares.dat'
     HEADERSTORE_FILENAME = 'namecoin_testnet_headers.dat'
 
+class IxcoinMainnet(ixcoin.IxcoinMainnet):
+    SHARE_PERIOD = 10 # seconds
+    CHAIN_LENGTH = 24*60*60//10 # shares
+    TARGET_LOOKBEHIND = 3600//10 # shares
+    SPREAD = 3 # blocks
+    SCRIPT = '41043da5beb73f8f18cede1a41b0ed953123f1342b8e0216ab5bf71ed3e024201b4017f472bddb6041f17978d89ed8f8ed84f9e726b0bca80cacf96347c7153e8df0ac'.decode('hex')
+    IDENTIFIER = '27b564116e2a2666'.decode('hex')
+    PREFIX = '9dd6c4a619401f2f'.decode('hex')
+    ADDRS_TABLE = 'addrs_ixcoin'
+    P2P_PORT = 9335
+    MAX_TARGET = 2**256//2**32 - 1
+    PERSIST = False
+    SHARESTORE_FILENAME = 'ixcoin_shares.dat'
+    HEADERSTORE_FILENAME = 'ixcoin_headers.dat'
+
+class IxcoinTestnet(ixcoin.IxcoinTestnet):
+    SHARE_PERIOD = 1 # seconds
+    CHAIN_LENGTH = 24*60*60//5 # shares
+    TARGET_LOOKBEHIND = 200 # shares
+    SPREAD = 3 # blocks
+    SCRIPT = '410403ad3dee8ab3d8a9ce5dd2abfbe7364ccd9413df1d279bf1a207849310465b0956e5904b1155ecd17574778f9949589ebfd4fb33ce837c241474a225cf08d85dac'.decode('hex')
+    IDENTIFIER = '7430cbeb01249e44'.decode('hex')
+    PREFIX = '7cfffda946709c1f'.decode('hex')
+    ADDRS_TABLE = 'addrs_ixcoin_testnet'
+    P2P_PORT = 19335
+    MAX_TARGET = 2**256//2**20 - 1
+    PERSIST = False
+    SHARESTORE_FILENAME = 'ixcoin_testnet_shares.dat'
+    HEADERSTORE_FILENAME = 'ixcoin_testnet_headers.dat'
diff --git a/p2pool/ixcoin.py b/p2pool/ixcoin.py
new file mode 100644 (file)
index 0000000..9fb92ec
--- /dev/null
@@ -0,0 +1,25 @@
+from twisted.internet import defer
+
+class IxcoinMainnet(object):
+    BITCOIN_P2P_PREFIX = 'f9beb4d9'.decode('hex')
+    BITCOIN_P2P_PORT = 8337
+    BITCOIN_ADDRESS_VERSION = 138
+    BITCOIN_RPC_PORT = 8338
+    BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
+        'name_firstupdate' not in (yield bitcoind.rpc_help()) and
+        'ixcoinaddress' in (yield bitcoind.rpc_help()) and
+        not (yield bitcoind.rpc_getinfo())['testnet']
+    )))
+    BITCOIN_SUBSIDY_FUNC = staticmethod(lambda height: 96*100000000 >> (height + 1)//210000)
+
+class IxcoinTestnet(object):
+    BITCOIN_P2P_PREFIX = 'fabfb5da'.decode('hex')
+    BITCOIN_P2P_PORT = 18337
+    BITCOIN_ADDRESS_VERSION = 111
+    BITCOIN_RPC_PORT = 8338
+    BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
+        'name_firstupdate' not in (yield bitcoind.rpc_help()) and
+        'ixcoinaddress' in (yield bitcoind.rpc_help()) and
+        (yield bitcoind.rpc_getinfo())['testnet']
+    )))
+    BITCOIN_SUBSIDY_FUNC = staticmethod(lambda height: 96*100000000 >> (height + 1)//210000)
index 55aeed8..e719d67 100644 (file)
@@ -599,9 +599,9 @@ def run():
     parser = argparse.ArgumentParser(description='p2pool (version %s)' % (p2pool_init.__version__,), fromfile_prefix_chars='@')
     parser.convert_arg_line_to_args = lambda arg_line: (arg for arg in arg_line.split() if arg.strip())
     parser.add_argument('--version', action='version', version=p2pool_init.__version__)
-    parser.add_argument('--namecoin',
-        help='use namecoin instead of bitcoin',
-        action='store_const', const=True, default=False, dest='namecoin')
+    parser.add_argument('--net',
+        help='use specified network (choices: bitcoin (default), namecoin, ixcoin)',
+        action='store', choices=set(['bitcoin', 'namecoin', 'ixcoin']), default='bitcoin', dest='net_name')
     parser.add_argument('--testnet',
         help='use the testnet',
         action='store_const', const=True, default=False, dest='testnet')
@@ -700,11 +700,13 @@ def run():
             signal.signal(signal.SIGUSR1, sigusr1)
     
     args.net = {
-        (False, False): p2pool.Mainnet,
-        (False, True): p2pool.Testnet,
-        (True, False): p2pool.NamecoinMainnet,
-        (True, True): p2pool.NamecoinTestnet,
-    }[args.namecoin, args.testnet]
+        ('bitcoin', False): p2pool.Mainnet,
+        ('bitcoin', True): p2pool.Testnet,
+        ('namecoin', False): p2pool.NamecoinMainnet,
+        ('namecoin', True): p2pool.NamecoinTestnet,
+        ('ixcoin', False): p2pool.IxcoinMainnet,
+        ('ixcoin', True): p2pool.IxcoinTestnet,
+    }[args.net_name, args.testnet]
     
     if args.bitcoind_p2p_port is None:
         args.bitcoind_p2p_port = args.net.BITCOIN_P2P_PORT
index da25465..81d6d75 100644 (file)
@@ -4,10 +4,22 @@ class NamecoinMainnet(object):
     BITCOIN_P2P_PREFIX = 'f9beb4fe'.decode('hex')
     BITCOIN_P2P_PORT = 8334
     BITCOIN_ADDRESS_VERSION = 52
-    BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue('name_firstupdate' in (yield bitcoind.rpc_help()) and not (yield bitcoind.rpc_getinfo())['testnet'])))
+    BITCOIN_RPC_PORT = 8332
+    BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
+        'name_firstupdate' in (yield bitcoind.rpc_help()) and
+        'ixcoinaddress' not in (yield bitcoind.rpc_help()) and
+        not (yield bitcoind.rpc_getinfo())['testnet']
+    )))
+    BITCOIN_SUBSIDY_FUNC = staticmethod(lambda height: 50*100000000 >> (height + 1)//210000)
 
 class NamecoinTestnet(object):
     BITCOIN_P2P_PREFIX = 'fabfb5fe'.decode('hex')
     BITCOIN_P2P_PORT = 18334
     BITCOIN_ADDRESS_VERSION = 111
-    BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue('name_firstupdate' in (yield bitcoind.rpc_help()) and (yield bitcoind.rpc_getinfo())['testnet'])))
+    BITCOIN_RPC_PORT = 8332
+    BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
+        'name_firstupdate' in (yield bitcoind.rpc_help()) and
+        'ixcoinaddress' not in (yield bitcoind.rpc_help()) and
+        (yield bitcoind.rpc_getinfo())['testnet']
+    )))
+    BITCOIN_SUBSIDY_FUNC = staticmethod(lambda height: 50*100000000 >> (height + 1)//210000)