added ability to customize SessionManager to torba
This commit is contained in:
parent
67e12bc590
commit
57f069d750
3 changed files with 11 additions and 2 deletions
|
@ -47,7 +47,7 @@ import torba.server.tx as lib_tx
|
|||
import torba.server.block_processor as block_proc
|
||||
from torba.server.db import DB
|
||||
import torba.server.daemon as daemon
|
||||
from torba.server.session import ElectrumX, DashElectrumX
|
||||
from torba.server.session import ElectrumX, DashElectrumX, SessionManager
|
||||
|
||||
|
||||
Block = namedtuple("Block", "raw header transactions")
|
||||
|
@ -72,6 +72,7 @@ class Coin:
|
|||
DESERIALIZER = lib_tx.Deserializer
|
||||
DAEMON = daemon.Daemon
|
||||
BLOCK_PROCESSOR = block_proc.BlockProcessor
|
||||
SESSION_MANAGER = SessionManager
|
||||
DB = DB
|
||||
HEADER_VALUES = [
|
||||
'version', 'prev_block_hash', 'merkle_root', 'timestamp', 'bits', 'nonce'
|
||||
|
|
|
@ -116,7 +116,7 @@ class Server:
|
|||
MemPoolAPI.register(Notifications)
|
||||
self.mempool = mempool = MemPool(env.coin, notifications)
|
||||
|
||||
self.session_mgr = SessionManager(
|
||||
self.session_mgr = env.coin.SESSION_MANAGER(
|
||||
env, db, bp, daemon, mempool, self.shutdown_event
|
||||
)
|
||||
|
||||
|
|
|
@ -523,6 +523,7 @@ class SessionManager:
|
|||
.format(self.env.drop_client.pattern))
|
||||
# Start notifications; initialize hsub_results
|
||||
await notifications.start(self.db.db_height, self._notify_sessions)
|
||||
await self.start_other()
|
||||
await self._start_external_servers()
|
||||
server_listening_event.set()
|
||||
# Peer discovery should start after the external servers
|
||||
|
@ -539,6 +540,13 @@ class SessionManager:
|
|||
await asyncio.wait([
|
||||
session.close(force_after=1) for session in self.sessions
|
||||
])
|
||||
await self.stop_other()
|
||||
|
||||
async def start_other(self):
|
||||
pass
|
||||
|
||||
async def stop_other(self):
|
||||
pass
|
||||
|
||||
def session_count(self) -> int:
|
||||
"""The number of connections that we've sent something to."""
|
||||
|
|
Loading…
Reference in a new issue