From 520079d1f01f13b6abc113da56ad2a485576c442 Mon Sep 17 00:00:00 2001 From: "io:nathan" Date: Sat, 29 Jun 2024 19:28:33 +0200 Subject: [PATCH] feat(network): add tx submission and tx monitor clients to network facades (#442) * added txsubmission client to network facades * added txmonitor::client to network facades --- pallas-network/src/facades.rs | 19 +++++++++++++++++-- pallas-network/src/miniprotocols/common.rs | 3 +++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pallas-network/src/facades.rs b/pallas-network/src/facades.rs index 76dbd60..c47458b 100644 --- a/pallas-network/src/facades.rs +++ b/pallas-network/src/facades.rs @@ -12,8 +12,9 @@ use tokio::net::{unix::SocketAddr as UnixSocketAddr, UnixListener}; use crate::miniprotocols::handshake::{n2c, n2n, Confirmation, VersionNumber}; use crate::miniprotocols::{ - blockfetch, chainsync, handshake, keepalive, localstate, txsubmission, PROTOCOL_N2C_CHAIN_SYNC, - PROTOCOL_N2C_HANDSHAKE, PROTOCOL_N2C_STATE_QUERY, PROTOCOL_N2N_BLOCK_FETCH, + blockfetch, chainsync, handshake, keepalive, localstate, localtxsubmission, txmonitor, + txsubmission, PROTOCOL_N2C_CHAIN_SYNC, PROTOCOL_N2C_HANDSHAKE, PROTOCOL_N2C_STATE_QUERY, + PROTOCOL_N2C_TX_MONITOR, PROTOCOL_N2C_TX_SUBMISSION, PROTOCOL_N2N_BLOCK_FETCH, PROTOCOL_N2N_CHAIN_SYNC, PROTOCOL_N2N_HANDSHAKE, PROTOCOL_N2N_KEEP_ALIVE, PROTOCOL_N2N_TX_SUBMISSION, }; @@ -285,6 +286,8 @@ pub struct NodeClient { handshake: handshake::N2CClient, chainsync: chainsync::N2CClient, statequery: localstate::Client, + submission: localtxsubmission::Client, + monitor: txmonitor::Client, } impl NodeClient { @@ -294,6 +297,8 @@ impl NodeClient { let hs_channel = plexer.subscribe_client(PROTOCOL_N2C_HANDSHAKE); let cs_channel = plexer.subscribe_client(PROTOCOL_N2C_CHAIN_SYNC); let sq_channel = plexer.subscribe_client(PROTOCOL_N2C_STATE_QUERY); + let tx_channel = plexer.subscribe_client(PROTOCOL_N2C_TX_SUBMISSION); + let mo_channel = plexer.subscribe_client(PROTOCOL_N2C_TX_MONITOR); let plexer = plexer.spawn(); @@ -302,6 +307,8 @@ impl NodeClient { handshake: handshake::Client::new(hs_channel), chainsync: chainsync::Client::new(cs_channel), statequery: localstate::Client::new(sq_channel), + submission: localtxsubmission::Client::new(tx_channel), + monitor: txmonitor::Client::new(mo_channel), } } @@ -406,6 +413,14 @@ impl NodeClient { &mut self.statequery } + pub fn submission(&mut self) -> &mut localtxsubmission::Client { + &mut self.submission + } + + pub fn monitor(&mut self) -> &mut txmonitor::Client { + &mut self.monitor + } + pub async fn abort(self) { self.plexer.abort().await } diff --git a/pallas-network/src/miniprotocols/common.rs b/pallas-network/src/miniprotocols/common.rs index b0d9167..5d454ce 100644 --- a/pallas-network/src/miniprotocols/common.rs +++ b/pallas-network/src/miniprotocols/common.rs @@ -63,6 +63,9 @@ pub const PROTOCOL_N2C_TX_SUBMISSION: u16 = 6; // Protocol channel number for node-to-client state queries pub const PROTOCOL_N2C_STATE_QUERY: u16 = 7; +// Protocol channel number for node-to-client mempool monitor +pub const PROTOCOL_N2C_TX_MONITOR: u16 = 9; + /// A point within a chain #[derive(Clone, Eq, PartialEq, Hash)] pub enum Point {