Browse Source

Allow custom ElectrumX class

master
TheLazieR Yip 8 years ago
parent
commit
b0e23e903d
  1. 2
      lib/coins.py
  2. 6
      server/controller.py

2
lib/coins.py

@ -42,6 +42,7 @@ from lib.script import ScriptPubKey
from lib.tx import Deserializer, DeserializerSegWit, DeserializerAuxPow, DeserializerZcash
from server.block_processor import BlockProcessor
from server.daemon import Daemon
from server.session import ElectrumX
Block = namedtuple("Block", "header transactions")
@ -61,6 +62,7 @@ class Coin(object):
HASHX_LEN = 11
BASIC_HEADER_SIZE = 80
STATIC_BLOCK_HEADERS = True
SESSIONCLS = ElectrumX
DESERIALIZER = Deserializer
DAEMON = Daemon
BLOCK_PROCESSOR = BlockProcessor

6
server/controller.py

@ -25,7 +25,7 @@ import lib.util as util
from server.daemon import DaemonError
from server.mempool import MemPool
from server.peers import PeerManager
from server.session import LocalRPC, ElectrumX
from server.session import LocalRPC
class Controller(util.LoggedClass):
@ -248,7 +248,7 @@ class Controller(util.LoggedClass):
server.close()
async def start_server(self, kind, *args, **kw_args):
protocol_class = LocalRPC if kind == 'RPC' else ElectrumX
protocol_class = LocalRPC if kind == 'RPC' else self.coin.SESSIONCLS
protocol_factory = partial(protocol_class, self, kind)
server = self.loop.create_server(protocol_factory, *args, **kw_args)
@ -309,7 +309,7 @@ class Controller(util.LoggedClass):
self.header_cache.clear()
# Make a copy; self.sessions can change whilst await-ing
sessions = [s for s in self.sessions if isinstance(s, ElectrumX)]
sessions = [s for s in self.sessions if isinstance(s, self.coin.SESSIONCLS)]
for session in sessions:
await session.notify(self.bp.db_height, touched)

Loading…
Cancel
Save