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
|
import torba.server.block_processor as block_proc
|
||||||
from torba.server.db import DB
|
from torba.server.db import DB
|
||||||
import torba.server.daemon as daemon
|
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")
|
Block = namedtuple("Block", "raw header transactions")
|
||||||
|
@ -72,6 +72,7 @@ class Coin:
|
||||||
DESERIALIZER = lib_tx.Deserializer
|
DESERIALIZER = lib_tx.Deserializer
|
||||||
DAEMON = daemon.Daemon
|
DAEMON = daemon.Daemon
|
||||||
BLOCK_PROCESSOR = block_proc.BlockProcessor
|
BLOCK_PROCESSOR = block_proc.BlockProcessor
|
||||||
|
SESSION_MANAGER = SessionManager
|
||||||
DB = DB
|
DB = DB
|
||||||
HEADER_VALUES = [
|
HEADER_VALUES = [
|
||||||
'version', 'prev_block_hash', 'merkle_root', 'timestamp', 'bits', 'nonce'
|
'version', 'prev_block_hash', 'merkle_root', 'timestamp', 'bits', 'nonce'
|
||||||
|
|
|
@ -116,7 +116,7 @@ class Server:
|
||||||
MemPoolAPI.register(Notifications)
|
MemPoolAPI.register(Notifications)
|
||||||
self.mempool = mempool = MemPool(env.coin, 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
|
env, db, bp, daemon, mempool, self.shutdown_event
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -523,6 +523,7 @@ class SessionManager:
|
||||||
.format(self.env.drop_client.pattern))
|
.format(self.env.drop_client.pattern))
|
||||||
# Start notifications; initialize hsub_results
|
# Start notifications; initialize hsub_results
|
||||||
await notifications.start(self.db.db_height, self._notify_sessions)
|
await notifications.start(self.db.db_height, self._notify_sessions)
|
||||||
|
await self.start_other()
|
||||||
await self._start_external_servers()
|
await self._start_external_servers()
|
||||||
server_listening_event.set()
|
server_listening_event.set()
|
||||||
# Peer discovery should start after the external servers
|
# Peer discovery should start after the external servers
|
||||||
|
@ -539,6 +540,13 @@ class SessionManager:
|
||||||
await asyncio.wait([
|
await asyncio.wait([
|
||||||
session.close(force_after=1) for session in self.sessions
|
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:
|
def session_count(self) -> int:
|
||||||
"""The number of connections that we've sent something to."""
|
"""The number of connections that we've sent something to."""
|
||||||
|
|
Loading…
Reference in a new issue