parent
a019fde853
commit
1856cbe6c0
75
lib/coins.py
75
lib/coins.py
@ -32,17 +32,18 @@ class CoinError(Exception):
|
|||||||
class Coin(object):
|
class Coin(object):
|
||||||
'''Base class of coin hierarchy.'''
|
'''Base class of coin hierarchy.'''
|
||||||
|
|
||||||
REORG_LIMIT=200
|
REORG_LIMIT = 200
|
||||||
# Not sure if these are coin-specific
|
# Not sure if these are coin-specific
|
||||||
RPC_URL_REGEX = re.compile('.+@[^:]+(:[0-9]+)?')
|
RPC_URL_REGEX = re.compile('.+@[^:]+(:[0-9]+)?')
|
||||||
VALUE_PER_COIN = 100000000
|
VALUE_PER_COIN = 100000000
|
||||||
CHUNK_SIZE=2016
|
CHUNK_SIZE = 2016
|
||||||
IRC_SERVER = "irc.freenode.net"
|
IRC_SERVER = "irc.freenode.net"
|
||||||
IRC_PORT = 6667
|
IRC_PORT = 6667
|
||||||
HASHX_LEN = 11
|
HASHX_LEN = 11
|
||||||
# Peer discovery
|
# Peer discovery
|
||||||
PEER_DEFAULT_PORTS = {'t':'50001', 's':'50002'}
|
PEER_DEFAULT_PORTS = {'t': '50001', 's': '50002'}
|
||||||
PEERS = []
|
PEERS = []
|
||||||
|
TX_COUNT_HEIGHT = 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def lookup_coin_class(cls, name, net):
|
def lookup_coin_class(cls, name, net):
|
||||||
@ -98,11 +99,11 @@ class Coin(object):
|
|||||||
@util.cachedproperty
|
@util.cachedproperty
|
||||||
def address_handlers(cls):
|
def address_handlers(cls):
|
||||||
return ScriptPubKey.PayToHandlers(
|
return ScriptPubKey.PayToHandlers(
|
||||||
address = cls.P2PKH_address_from_hash160,
|
address=cls.P2PKH_address_from_hash160,
|
||||||
script_hash = cls.P2SH_address_from_hash160,
|
script_hash=cls.P2SH_address_from_hash160,
|
||||||
pubkey = cls.P2PKH_address_from_pubkey,
|
pubkey=cls.P2PKH_address_from_pubkey,
|
||||||
unspendable = lambda : None,
|
unspendable=lambda: None,
|
||||||
strange = lambda script: None,
|
strange=lambda script: None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -269,8 +270,8 @@ class Bitcoin(Coin):
|
|||||||
P2PKH_VERBYTE = 0x00
|
P2PKH_VERBYTE = 0x00
|
||||||
P2SH_VERBYTE = 0x05
|
P2SH_VERBYTE = 0x05
|
||||||
WIF_BYTE = 0x80
|
WIF_BYTE = 0x80
|
||||||
GENESIS_HASH=('000000000019d6689c085ae165831e93'
|
GENESIS_HASH = ('000000000019d6689c085ae165831e93'
|
||||||
'4ff763ae46a2a6c172b3f1b60a8ce26f')
|
'4ff763ae46a2a6c172b3f1b60a8ce26f')
|
||||||
TX_COUNT = 156335304
|
TX_COUNT = 156335304
|
||||||
TX_COUNT_HEIGHT = 429972
|
TX_COUNT_HEIGHT = 429972
|
||||||
TX_PER_BLOCK = 1800
|
TX_PER_BLOCK = 1800
|
||||||
@ -302,15 +303,15 @@ class BitcoinTestnet(Bitcoin):
|
|||||||
P2PKH_VERBYTE = 0x6f
|
P2PKH_VERBYTE = 0x6f
|
||||||
P2SH_VERBYTE = 0xc4
|
P2SH_VERBYTE = 0xc4
|
||||||
WIF_BYTE = 0xef
|
WIF_BYTE = 0xef
|
||||||
GENESIS_HASH=('000000000933ea01ad0ee984209779ba'
|
GENESIS_HASH = ('000000000933ea01ad0ee984209779ba'
|
||||||
'aec3ced90fa3f408719526f8d77f4943')
|
'aec3ced90fa3f408719526f8d77f4943')
|
||||||
REORG_LIMIT = 2000
|
REORG_LIMIT = 2000
|
||||||
TX_COUNT = 12242438
|
TX_COUNT = 12242438
|
||||||
TX_COUNT_HEIGHT = 1035428
|
TX_COUNT_HEIGHT = 1035428
|
||||||
TX_PER_BLOCK = 21
|
TX_PER_BLOCK = 21
|
||||||
IRC_PREFIX = "ET_"
|
IRC_PREFIX = "ET_"
|
||||||
RPC_PORT = 18332
|
RPC_PORT = 18332
|
||||||
PEER_DEFAULT_PORTS = {'t':'51001', 's':'51002'}
|
PEER_DEFAULT_PORTS = {'t': '51001', 's': '51002'}
|
||||||
PEERS = [
|
PEERS = [
|
||||||
'electrum.akinbo.org s t',
|
'electrum.akinbo.org s t',
|
||||||
'he36kyperp3kbuxu.onion s t',
|
'he36kyperp3kbuxu.onion s t',
|
||||||
@ -319,6 +320,7 @@ class BitcoinTestnet(Bitcoin):
|
|||||||
'testnet.not.fyi s t',
|
'testnet.not.fyi s t',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class BitcoinTestnetSegWit(BitcoinTestnet):
|
class BitcoinTestnetSegWit(BitcoinTestnet):
|
||||||
'''Bitcoin Testnet for Core bitcoind >= 0.13.1.
|
'''Bitcoin Testnet for Core bitcoind >= 0.13.1.
|
||||||
|
|
||||||
@ -343,8 +345,8 @@ class Litecoin(Coin):
|
|||||||
P2PKH_VERBYTE = 0x30
|
P2PKH_VERBYTE = 0x30
|
||||||
P2SH_VERBYTE = 0x05
|
P2SH_VERBYTE = 0x05
|
||||||
WIF_BYTE = 0xb0
|
WIF_BYTE = 0xb0
|
||||||
GENESIS_HASH=('12a765e31ffd4059bada1e25190f6e98'
|
GENESIS_HASH = ('12a765e31ffd4059bada1e25190f6e98'
|
||||||
'c99d9714d334efa41a195a7e7e04bfe2')
|
'c99d9714d334efa41a195a7e7e04bfe2')
|
||||||
TX_COUNT = 8908766
|
TX_COUNT = 8908766
|
||||||
TX_COUNT_HEIGHT = 1105256
|
TX_COUNT_HEIGHT = 1105256
|
||||||
TX_PER_BLOCK = 10
|
TX_PER_BLOCK = 10
|
||||||
@ -361,7 +363,8 @@ class LitecoinTestnet(Litecoin):
|
|||||||
P2PKH_VERBYTE = 0x6f
|
P2PKH_VERBYTE = 0x6f
|
||||||
P2SH_VERBYTE = 0xc4
|
P2SH_VERBYTE = 0xc4
|
||||||
WIF_BYTE = 0xef
|
WIF_BYTE = 0xef
|
||||||
# Some details missing...
|
GENESIS_HASH = ('f5ae71e26c74beacc88382716aced69c'
|
||||||
|
'ddf3dffff24f384e1808905e0188f68f')
|
||||||
|
|
||||||
|
|
||||||
# Source: namecoin.org
|
# Source: namecoin.org
|
||||||
@ -374,9 +377,11 @@ class Namecoin(Coin):
|
|||||||
P2PKH_VERBYTE = 0x34
|
P2PKH_VERBYTE = 0x34
|
||||||
P2SH_VERBYTE = 0x0d
|
P2SH_VERBYTE = 0x0d
|
||||||
WIF_BYTE = 0xe4
|
WIF_BYTE = 0xe4
|
||||||
|
GENESIS_HASH = ('000000000062b72c5e2ceb45fbc8587e'
|
||||||
|
'807c155b0da735e6483dfba2f0a9c770')
|
||||||
|
|
||||||
|
|
||||||
class NamecoinTestnet(Coin):
|
class NamecoinTestnet(Namecoin):
|
||||||
NAME = "Namecoin"
|
NAME = "Namecoin"
|
||||||
SHORTNAME = "XNM"
|
SHORTNAME = "XNM"
|
||||||
NET = "testnet"
|
NET = "testnet"
|
||||||
@ -385,6 +390,7 @@ class NamecoinTestnet(Coin):
|
|||||||
P2PKH_VERBYTE = 0x6f
|
P2PKH_VERBYTE = 0x6f
|
||||||
P2SH_VERBYTE = 0xc4
|
P2SH_VERBYTE = 0xc4
|
||||||
WIF_BYTE = 0xef
|
WIF_BYTE = 0xef
|
||||||
|
# TODO add GENESIS_HASH
|
||||||
|
|
||||||
|
|
||||||
# For DOGE there is disagreement across sites like bip32.org and
|
# For DOGE there is disagreement across sites like bip32.org and
|
||||||
@ -398,9 +404,11 @@ class Dogecoin(Coin):
|
|||||||
P2PKH_VERBYTE = 0x1e
|
P2PKH_VERBYTE = 0x1e
|
||||||
P2SH_VERBYTE = 0x16
|
P2SH_VERBYTE = 0x16
|
||||||
WIF_BYTE = 0x9e
|
WIF_BYTE = 0x9e
|
||||||
|
GENESIS_HASH = ('1a91e3dace36e2be3bf030a65679fe82'
|
||||||
|
'1aa1d6ef92e7c9902eb318182c355691')
|
||||||
|
|
||||||
|
|
||||||
class DogecoinTestnet(Coin):
|
class DogecoinTestnet(Dogecoin):
|
||||||
NAME = "Dogecoin"
|
NAME = "Dogecoin"
|
||||||
SHORTNAME = "XDT"
|
SHORTNAME = "XDT"
|
||||||
NET = "testnet"
|
NET = "testnet"
|
||||||
@ -409,6 +417,8 @@ class DogecoinTestnet(Coin):
|
|||||||
P2PKH_VERBYTE = 0x71
|
P2PKH_VERBYTE = 0x71
|
||||||
P2SH_VERBYTE = 0xc4
|
P2SH_VERBYTE = 0xc4
|
||||||
WIF_BYTE = 0xf1
|
WIF_BYTE = 0xf1
|
||||||
|
GENESIS_HASH = ('bb0a78264637406b6360aad926284d54'
|
||||||
|
'4d7049f45189db5664f3c4d07350559e')
|
||||||
|
|
||||||
|
|
||||||
# Source: https://github.com/dashpay/dash
|
# Source: https://github.com/dashpay/dash
|
||||||
@ -436,6 +446,7 @@ class Dash(Coin):
|
|||||||
import x11_hash
|
import x11_hash
|
||||||
return x11_hash.getPoWHash(header)
|
return x11_hash.getPoWHash(header)
|
||||||
|
|
||||||
|
|
||||||
class DashTestnet(Dash):
|
class DashTestnet(Dash):
|
||||||
SHORTNAME = "tDASH"
|
SHORTNAME = "tDASH"
|
||||||
NET = "testnet"
|
NET = "testnet"
|
||||||
@ -462,8 +473,8 @@ class Argentum(Coin):
|
|||||||
P2PKH_VERBYTE = 0x17
|
P2PKH_VERBYTE = 0x17
|
||||||
P2SH_VERBYTE = 0x05
|
P2SH_VERBYTE = 0x05
|
||||||
WIF_BYTE = 0x97
|
WIF_BYTE = 0x97
|
||||||
GENESIS_HASH=('88c667bc63167685e4e4da058fffdfe8'
|
GENESIS_HASH = ('88c667bc63167685e4e4da058fffdfe8'
|
||||||
'e007e5abffd6855de52ad59df7bb0bb2')
|
'e007e5abffd6855de52ad59df7bb0bb2')
|
||||||
TX_COUNT = 2263089
|
TX_COUNT = 2263089
|
||||||
TX_COUNT_HEIGHT = 2050260
|
TX_COUNT_HEIGHT = 2050260
|
||||||
TX_PER_BLOCK = 2000
|
TX_PER_BLOCK = 2000
|
||||||
@ -473,14 +484,14 @@ class Argentum(Coin):
|
|||||||
|
|
||||||
|
|
||||||
class ArgentumTestnet(Argentum):
|
class ArgentumTestnet(Argentum):
|
||||||
SHORTNAME = "XRG"
|
SHORTNAME = "XRG"
|
||||||
NET = "testnet"
|
NET = "testnet"
|
||||||
XPUB_VERBYTES = bytes.fromhex("043587cf")
|
XPUB_VERBYTES = bytes.fromhex("043587cf")
|
||||||
XPRV_VERBYTES = bytes.fromhex("04358394")
|
XPRV_VERBYTES = bytes.fromhex("04358394")
|
||||||
P2PKH_VERBYTE = 0x6f
|
P2PKH_VERBYTE = 0x6f
|
||||||
P2SH_VERBYTE = 0xc4
|
P2SH_VERBYTE = 0xc4
|
||||||
WIF_BYTE = 0xef
|
WIF_BYTE = 0xef
|
||||||
REORG_LIMIT = 2000
|
REORG_LIMIT = 2000
|
||||||
|
|
||||||
|
|
||||||
class DigiByte(Coin):
|
class DigiByte(Coin):
|
||||||
@ -492,8 +503,8 @@ class DigiByte(Coin):
|
|||||||
P2PKH_VERBYTE = 0x1E
|
P2PKH_VERBYTE = 0x1E
|
||||||
P2SH_VERBYTE = 0x05
|
P2SH_VERBYTE = 0x05
|
||||||
WIF_BYTE = 0x80
|
WIF_BYTE = 0x80
|
||||||
GENESIS_HASH=('7497ea1b465eb39f1c8f507bc877078f'
|
GENESIS_HASH = ('7497ea1b465eb39f1c8f507bc877078f'
|
||||||
'e016d6fcb6dfad3a64c98dcc6e1e8496')
|
'e016d6fcb6dfad3a64c98dcc6e1e8496')
|
||||||
TX_COUNT = 1046018
|
TX_COUNT = 1046018
|
||||||
TX_COUNT_HEIGHT = 1435000
|
TX_COUNT_HEIGHT = 1435000
|
||||||
TX_PER_BLOCK = 1000
|
TX_PER_BLOCK = 1000
|
||||||
@ -509,8 +520,8 @@ class DigiByteTestnet(DigiByte):
|
|||||||
P2PKH_VERBYTE = 0x6f
|
P2PKH_VERBYTE = 0x6f
|
||||||
P2SH_VERBYTE = 0xc4
|
P2SH_VERBYTE = 0xc4
|
||||||
WIF_BYTE = 0xef
|
WIF_BYTE = 0xef
|
||||||
GENESIS_HASH=('b5dca8039e300198e5fe7cd23bdd1728'
|
GENESIS_HASH = ('b5dca8039e300198e5fe7cd23bdd1728'
|
||||||
'e2a444af34c447dbd0916fa3430a68c2')
|
'e2a444af34c447dbd0916fa3430a68c2')
|
||||||
IRC_PREFIX = "DET_"
|
IRC_PREFIX = "DET_"
|
||||||
IRC_CHANNEL = "#electrum-dgb"
|
IRC_CHANNEL = "#electrum-dgb"
|
||||||
RPC_PORT = 15022
|
RPC_PORT = 15022
|
||||||
|
|||||||
@ -383,26 +383,32 @@ class BlockProcessor(server.db.DB):
|
|||||||
|
|
||||||
# Catch-up stats
|
# Catch-up stats
|
||||||
if self.utxo_db.for_sync:
|
if self.utxo_db.for_sync:
|
||||||
daemon_height = self.daemon.cached_height()
|
|
||||||
tx_per_sec = int(self.tx_count / self.wall_time)
|
tx_per_sec = int(self.tx_count / self.wall_time)
|
||||||
this_tx_per_sec = 1 + int(tx_diff / (self.last_flush - last_flush))
|
this_tx_per_sec = 1 + int(tx_diff / (self.last_flush - last_flush))
|
||||||
if self.height > self.coin.TX_COUNT_HEIGHT:
|
|
||||||
tx_est = (daemon_height - self.height) * self.coin.TX_PER_BLOCK
|
|
||||||
else:
|
|
||||||
tx_est = ((daemon_height - self.coin.TX_COUNT_HEIGHT)
|
|
||||||
* self.coin.TX_PER_BLOCK
|
|
||||||
+ (self.coin.TX_COUNT - self.tx_count))
|
|
||||||
|
|
||||||
# Damp the enthusiasm
|
|
||||||
realism = 2.0 - 0.9 * self.height / self.coin.TX_COUNT_HEIGHT
|
|
||||||
tx_est *= max(realism, 1.0)
|
|
||||||
|
|
||||||
self.logger.info('tx/sec since genesis: {:,d}, '
|
self.logger.info('tx/sec since genesis: {:,d}, '
|
||||||
'since last flush: {:,d}'
|
'since last flush: {:,d}'
|
||||||
.format(tx_per_sec, this_tx_per_sec))
|
.format(tx_per_sec, this_tx_per_sec))
|
||||||
self.logger.info('sync time: {} ETA: {}'
|
if self.coin.TX_COUNT_HEIGHT > 0:
|
||||||
.format(formatted_time(self.wall_time),
|
daemon_height = self.daemon.cached_height()
|
||||||
formatted_time(tx_est / this_tx_per_sec)))
|
if self.height > self.coin.TX_COUNT_HEIGHT:
|
||||||
|
tx_est = (daemon_height - self.height) * self.coin.TX_PER_BLOCK
|
||||||
|
else:
|
||||||
|
tx_est = ((daemon_height - self.coin.TX_COUNT_HEIGHT)
|
||||||
|
* self.coin.TX_PER_BLOCK
|
||||||
|
+ (self.coin.TX_COUNT - self.tx_count))
|
||||||
|
|
||||||
|
# Damp the enthusiasm
|
||||||
|
realism = 2.0 - 0.9 * self.height / self.coin.TX_COUNT_HEIGHT
|
||||||
|
tx_est *= max(realism, 1.0)
|
||||||
|
|
||||||
|
|
||||||
|
self.logger.info('sync time: {} ETA: {}'
|
||||||
|
.format(formatted_time(self.wall_time),
|
||||||
|
formatted_time(tx_est / this_tx_per_sec)))
|
||||||
|
else:
|
||||||
|
self.logger.info('sync time: {}'
|
||||||
|
.format(formatted_time(self.wall_time)))
|
||||||
|
|
||||||
|
|
||||||
def fs_flush(self):
|
def fs_flush(self):
|
||||||
'''Flush the things stored on the filesystem.'''
|
'''Flush the things stored on the filesystem.'''
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user