Merge pull request #182 from thelazier/allow_custom_electrumx
Allow custom ElectrumX class
This commit is contained in:
commit
d3348fe684
@ -42,6 +42,7 @@ from lib.script import ScriptPubKey
|
|||||||
from lib.tx import Deserializer, DeserializerSegWit, DeserializerAuxPow, DeserializerZcash
|
from lib.tx import Deserializer, DeserializerSegWit, DeserializerAuxPow, DeserializerZcash
|
||||||
from server.block_processor import BlockProcessor
|
from server.block_processor import BlockProcessor
|
||||||
from server.daemon import Daemon
|
from server.daemon import Daemon
|
||||||
|
from server.session import ElectrumX
|
||||||
|
|
||||||
Block = namedtuple("Block", "header transactions")
|
Block = namedtuple("Block", "header transactions")
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ class Coin(object):
|
|||||||
HASHX_LEN = 11
|
HASHX_LEN = 11
|
||||||
BASIC_HEADER_SIZE = 80
|
BASIC_HEADER_SIZE = 80
|
||||||
STATIC_BLOCK_HEADERS = True
|
STATIC_BLOCK_HEADERS = True
|
||||||
|
SESSIONCLS = ElectrumX
|
||||||
DESERIALIZER = Deserializer
|
DESERIALIZER = Deserializer
|
||||||
DAEMON = Daemon
|
DAEMON = Daemon
|
||||||
BLOCK_PROCESSOR = BlockProcessor
|
BLOCK_PROCESSOR = BlockProcessor
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import lib.util as util
|
|||||||
from server.daemon import DaemonError
|
from server.daemon import DaemonError
|
||||||
from server.mempool import MemPool
|
from server.mempool import MemPool
|
||||||
from server.peers import PeerManager
|
from server.peers import PeerManager
|
||||||
from server.session import LocalRPC, ElectrumX
|
from server.session import LocalRPC
|
||||||
|
|
||||||
|
|
||||||
class Controller(util.LoggedClass):
|
class Controller(util.LoggedClass):
|
||||||
@ -248,7 +248,7 @@ class Controller(util.LoggedClass):
|
|||||||
server.close()
|
server.close()
|
||||||
|
|
||||||
async def start_server(self, kind, *args, **kw_args):
|
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)
|
protocol_factory = partial(protocol_class, self, kind)
|
||||||
server = self.loop.create_server(protocol_factory, *args, **kw_args)
|
server = self.loop.create_server(protocol_factory, *args, **kw_args)
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ class Controller(util.LoggedClass):
|
|||||||
self.header_cache.clear()
|
self.header_cache.clear()
|
||||||
|
|
||||||
# Make a copy; self.sessions can change whilst await-ing
|
# 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:
|
for session in sessions:
|
||||||
await session.notify(self.bp.db_height, touched)
|
await session.notify(self.bp.db_height, touched)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user