Disable IRC for bitcoin mainnet
Only require IRC_CHANNEL if IRC_PREFIX is given.
This commit is contained in:
parent
9a9f78030d
commit
4cc3720589
13
lib/coins.py
13
lib/coins.py
@ -78,12 +78,14 @@ class Coin(object):
|
|||||||
'''Return a coin class given name and network.
|
'''Return a coin class given name and network.
|
||||||
|
|
||||||
Raise an exception if unrecognised.'''
|
Raise an exception if unrecognised.'''
|
||||||
req_attrs = ('TX_COUNT', 'TX_COUNT_HEIGHT', 'TX_PER_BLOCK',
|
req_attrs = ['TX_COUNT', 'TX_COUNT_HEIGHT', 'TX_PER_BLOCK']
|
||||||
'IRC_CHANNEL')
|
|
||||||
for coin in util.subclasses(Coin):
|
for coin in util.subclasses(Coin):
|
||||||
if (coin.NAME.lower() == name.lower() and
|
if (coin.NAME.lower() == name.lower() and
|
||||||
coin.NET.lower() == net.lower()):
|
coin.NET.lower() == net.lower()):
|
||||||
missing = [attr for attr in req_attrs
|
coin_req_attrs = req_attrs.copy()
|
||||||
|
if coin.IRC_PREFIX is not None:
|
||||||
|
coin_req_attrs.append('IRC_CHANNEL')
|
||||||
|
missing = [attr for attr in coin_req_attrs
|
||||||
if not hasattr(coin, attr)]
|
if not hasattr(coin, attr)]
|
||||||
if missing:
|
if missing:
|
||||||
raise CoinError('coin {} missing {} attributes'
|
raise CoinError('coin {} missing {} attributes'
|
||||||
@ -329,8 +331,6 @@ class Bitcoin(Coin):
|
|||||||
TX_COUNT = 217380620
|
TX_COUNT = 217380620
|
||||||
TX_COUNT_HEIGHT = 464000
|
TX_COUNT_HEIGHT = 464000
|
||||||
TX_PER_BLOCK = 1800
|
TX_PER_BLOCK = 1800
|
||||||
IRC_PREFIX = "E_"
|
|
||||||
IRC_CHANNEL = "#electrum"
|
|
||||||
RPC_PORT = 8332
|
RPC_PORT = 8332
|
||||||
PEERS = [
|
PEERS = [
|
||||||
'btc.smsys.me s995',
|
'btc.smsys.me s995',
|
||||||
@ -353,7 +353,6 @@ class Bitcoin(Coin):
|
|||||||
class BitcoinTestnet(Bitcoin):
|
class BitcoinTestnet(Bitcoin):
|
||||||
SHORTNAME = "XTN"
|
SHORTNAME = "XTN"
|
||||||
NET = "testnet"
|
NET = "testnet"
|
||||||
IRC_PREFIX = None
|
|
||||||
XPUB_VERBYTES = bytes.fromhex("043587cf")
|
XPUB_VERBYTES = bytes.fromhex("043587cf")
|
||||||
XPRV_VERBYTES = bytes.fromhex("04358394")
|
XPRV_VERBYTES = bytes.fromhex("04358394")
|
||||||
P2PKH_VERBYTE = bytes.fromhex("6f")
|
P2PKH_VERBYTE = bytes.fromhex("6f")
|
||||||
@ -422,8 +421,6 @@ class Litecoin(Coin):
|
|||||||
TX_COUNT = 8908766
|
TX_COUNT = 8908766
|
||||||
TX_COUNT_HEIGHT = 1105256
|
TX_COUNT_HEIGHT = 1105256
|
||||||
TX_PER_BLOCK = 10
|
TX_PER_BLOCK = 10
|
||||||
IRC_CHANNEL = "#electrum-ltc" # obsolete
|
|
||||||
IRC_PREFIX = None
|
|
||||||
RPC_PORT = 9332
|
RPC_PORT = 9332
|
||||||
REORG_LIMIT = 800
|
REORG_LIMIT = 800
|
||||||
PEERS = [
|
PEERS = [
|
||||||
|
|||||||
@ -216,7 +216,10 @@ class PeerManager(util.LoggedClass):
|
|||||||
self.env = env
|
self.env = env
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
self.loop = controller.loop
|
self.loop = controller.loop
|
||||||
self.irc = IRC(env, self)
|
if env.irc and env.coin.IRC_PREFIX:
|
||||||
|
self.irc = IRC(env, self)
|
||||||
|
else:
|
||||||
|
self.irc = None
|
||||||
self.myselves = peers_from_env(env)
|
self.myselves = peers_from_env(env)
|
||||||
self.retry_event = asyncio.Event()
|
self.retry_event = asyncio.Event()
|
||||||
# Peers have one entry per hostname. Once connected, the
|
# Peers have one entry per hostname. Once connected, the
|
||||||
@ -438,10 +441,12 @@ class PeerManager(util.LoggedClass):
|
|||||||
|
|
||||||
def connect_to_irc(self):
|
def connect_to_irc(self):
|
||||||
'''Connect to IRC if not disabled.'''
|
'''Connect to IRC if not disabled.'''
|
||||||
if self.env.irc and self.env.coin.IRC_PREFIX:
|
if self.irc:
|
||||||
pairs = [(peer.real_name(), ident.nick_suffix) for peer, ident
|
pairs = [(peer.real_name(), ident.nick_suffix) for peer, ident
|
||||||
in zip(self.myselves, self.env.identities)]
|
in zip(self.myselves, self.env.identities)]
|
||||||
self.ensure_future(self.irc.start(pairs))
|
self.ensure_future(self.irc.start(pairs))
|
||||||
|
elif self.env.irc:
|
||||||
|
self.logger.info('IRC is disabled for this coin')
|
||||||
else:
|
else:
|
||||||
self.logger.info('IRC is disabled')
|
self.logger.info('IRC is disabled')
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user